cxf 命名空间的前缀

qwwwwwqqqq 2016-11-02 08:18:10
最近在研究java的webservice,用的是cxf框架。一切顺利,但是就是看着默认生成的命名空间前缀有点不爽
这个是接口
@WebService(targetNamespace="http://www.hehe.shabi.com",name="hehe",serviceName="heheService")
public interface ITestService {
@WebResult(name = "RESULT")
String syaHello(@WebParam(name="name") String name);
}

这个是实现
public class TestService implements ITestService {

public String syaHello(String name) {
return name + ",你好";
}

}

spring里面的配置
<bean id="test" class="TestService"></bean>

<jaxws:endpoint implementor="#test" address="/test">
</jaxws:endpoint>


这个是用soapui生成的调用
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:hehe="http://www.hehe.shabi.com">
<soapenv:Header/>
<soapenv:Body>
<hehe:syaHello>
<name>34</name>
</hehe:syaHello>
</soapenv:Body>
</soapenv:Envelope>


syaHello 的前缀hehe是根据命名空间生成的,拿命名空间不就被固定了,不能更改成器他的,如改动的话,拿前缀也会发生变化,这个前缀可以单独设置吗?

响应更是有点尴尬了
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:syaHelloResponse xmlns:ns2="http://www.hehe.shabi.com">
<RESULT>34,你好</RESULT>
</ns2:syaHelloResponse>
</soap:Body>
</soap:Envelope>


这个ns2更是哪里冒出来的,可以自由设置吗?syaHelloResponse 里面引入了ns2,这个可以在soap:Envelope中引入吗?

看了网上说的,加了个属性
<jaxws:endpoint implementor="#test" address="/test">
<jaxws:properties>
<entry key="soap.env.ns.map">
<map>
<entry value="http://www.hehe.shabi.net" key="hehe"></entry>
</map>
</entry>
</jaxws:properties>
</jaxws:endpoint>

调用没有什么变化,但是响应就有点看不懂了
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:hehe="http://www.hehe.shabi.net">
<soap:Body>
<ns2:syaHelloResponse xmlns:ns2="http://www.hehe.shabi.com">
<RESULT>34,你好</RESULT>
</ns2:syaHelloResponse>
</soap:Body>
</soap:Envelope>


求助命名空间这个前缀具体要怎么设置?
...全文
5368 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Rainy_Iboy 2019-11-14
  • 打赏
  • 举报
回复
最后命名空间前缀是怎么去掉的?
AnnoyR 2017-10-20
  • 打赏
  • 举报
回复
按照http://cxf.547215.n5.nabble.com/How-to-customize-namespaces-position-and-prefix-in-CXF-response-td3423069.html这个的说明,应该在.xml配置文件中加 <entry key="disable.outputstream.optimization" value="true"/> XML文件的配置应该是 <jaxws:endpoint id="doubleHotline" implementor="#doubleHotlineService" address="/doubleHotline"> <jaxws:properties> <entry key="soap.env.ns.map"> <map> <entry value="http://esb.lzccb.com" key="esb"></entry> <entry value="http://esb.lzccb.com/business/callcenter/DouHotLineService" key="douh"></entry> </map> </entry> <entry key="disable.outputstream.optimization" value="true"/> </jaxws:properties> <jaxws:inInterceptors> <ref bean="loggingInInterceptor"/> </jaxws:inInterceptors> <jaxws:outInterceptors> <ref bean="loggingOutInterceptor" /> </jaxws:outInterceptors> </jaxws:endpoint> 最后用SoapUI测试出来的响应报文是: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:esb="http://esb.lzccb.com" xmlns:douh="http://esb.lzccb.com/business/callcenter/DouHotLineService"> <soap:Header> <esb:RouteInformation> <esb:SourceId>?</esb:SourceId> <esb:AuthCode>?</esb:AuthCode> <esb:GoalId>?</esb:GoalId> <esb:ServiceName>?</esb:ServiceName> <esb:OperationName>?</esb:OperationName> <esb:RouteMsgId>?</esb:RouteMsgId> <esb:TimeOut>?</esb:TimeOut> <esb:RelatesTo>?</esb:RelatesTo> </esb:RouteInformation> </soap:Header> <soap:Body> <douh:doubleHotLineResponse> <douh:ResponseType>E</douh:ResponseType> <douh:ResponseCode>111000</douh:ResponseCode> <douh:ResponseMessage>明细字段内容不符合规范</douh:ResponseMessage> <douh:doubleHotLineRespData/> </douh:doubleHotLineResponse> </soap:Body> </soap:Envelope>
UncleZp 2017-01-12
  • 打赏
  • 举报
回复
大神,您的name怎么加命名空间前缀呢?现在我在用cxf发布webservice遇到俩个问题:1、修改命名空间只能修改默认命名空间的包名么?2、输入参数为实体类,发布的报文实体类的前面怎么加命名空间前缀呢?
yhhr1 2016-12-13
  • 打赏
  • 举报
回复
。。。。。。。。。。。。。。。。。。。。。。。。
qwwwwwqqqq 2016-11-04
  • 打赏
  • 举报
回复
怎么能没人呢,webservice这么成熟的技术了。。。。。。。。。。。。。。。。。。

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧