cxf生成endpoint,使用soap1.1和soap1.2

开发了一个web service服务,客户居然不认,查看客户发过来的请求,其soap header是
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope">

但我们给回的响应soap header是
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">

查了一下资料,发现客户发过来的是soap1.1的header,我们的响应却是soap1.2的header,所以怀疑是不是这里出了问题

由于我们的服务端是根据wsdl证书反向生成的,所以就先查了一下原始wsdl
<wsdl:service name="inbound.webServices.ticket.saService">
		<wsdl:port name="inbound.webServices.ticket.saServiceSoap" binding="tns:inbound.webServices.ticket.saServiceSoap">
			<soap:address location="http://localhost:49169/saService.asmx" />
		</wsdl:port>
		<wsdl:port name="inbound.webServices.ticket.saServiceSoap12" binding="tns:inbound.webServices.ticket.saServiceSoap12">
			<soap12:address location="http://localhost:49169/saService.asmx" />
		</wsdl:port>
	</wsdl:service>

可以看到,wsdl同时声明了soap11和soap12,上网查了一下,在cxf的配置文件里增加了以下的配置

<jaxws:endpoint id="sp" implementor="xxx" address="/WebServiceSP">
                <jaxws:binding>
			<soap:soapBinding version="1.1" />
		</jaxws:binding>
</jaxws:endpoint>

重启应用以后,发现没有生效,不知道是为什么

于是又检查了web service实现类的代码,发现类开头的注解是这么写的:
@WebService(serviceName = "xxx", portName = "inbound.webServices.ticket.saServiceSoap12", targetNamespace = "xxx", wsdlLocation = "xxx/saService.wsdl", endpointInterface = "xxx")

看来看去,觉得就是portName最为可疑,把这里改成:
@WebService(serviceName = "xxx", portName = "inbound.webServices.ticket.saServiceSoap", targetNamespace = "xxx", wsdlLocation = "xxx/saService.wsdl", endpointInterface = "xxx")

再重启应用就OK了

你可能感兴趣的:(CXF,SOAP,soap12)