我需要部署合同第一个Web服务。服务本身非常简单,只需一个ping操作来检查系统是否可用。
Ping.wsdl:
<?xml version="1.0" encoding="utf-8"?>
<definitions targetNamespace="urn:hl7-org:v3" name="Ping" xmlns:hl7="urn:hl7-org:v3" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types>
<xsd:schema targetNamespace="urn:hl7-org:v3" elementFormDefault="qualified" xmlns:hl7="urn:hl7-org:v3" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:include schemaLocation="../schemas_codeGen/COMT_IN118118.xsd" />
<xsd:include schemaLocation="../schemas_codeGen/COMT_IN229229.xsd" />
</xsd:schema>
</types>
<message name="COMT_IN118118"><part name="body" element="hl7:COMT_IN118118" /></message>
<message name="COMT_IN229229"><part name="body" element="hl7:COMT_IN229229" /></message>
<portType name="Ping_PortType">
<operation name="Ping_PingPong">
<input message="hl7:COMT_IN118118" />
<output message="hl7:COMT_IN229229" />
</operation>
</portType>
<binding type="hl7:Ping_PortType" name="Ping_Binding">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="Ping_PingPong">
<soap:operation soapAction="urn:hl7-org:v3/Ping_PingPong" />
<input><soap:body use="literal" /></input>
<output><soap:body use="literal" /></output>
</operation>
</binding>
<service name="Ping_Service">
<port binding="hl7:Ping_Binding" name="Ping_Port"><soap:address location="http:/www.xis.nl/Ping" /></port>
</service>
</definitions>
我应该可以在远程控制上调用此Web服务并提供此服务,以便远程可以在我的计算机上调用该服务。我使用wsimport从WSDL生成Java代码,导致COMT_IN118118和COMT_IN229229消息的Java类以及带有必要注释的接口PingPortType:
@WebService(name = "Ping_PortType", targetNamespace = "urn:hl7-org:v3")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
ObjectFactory.class
})
public interface PingPortType {
@WebMethod(operationName = "Ping_PingPong", action = "urn:hl7-org:v3/Ping_PingPong")
@WebResult(name = "COMT_IN229229", targetNamespace = "urn:hl7-org:v3", partName = "body")
public COMTIN229229MCCIMT000300Message pingPingPong(
@WebParam(name = "COMT_IN118118", targetNamespace = "urn:hl7-org:v3", partName = "body")
COMTIN118118MCCIMT000100Message body);
}
我想通过spring部署我的服务并添加到我的applicationContext:
<jaxws:endpoint id="pingEndpoint" address="/Ping"
implementor="com.application.services.impl.PingServiceImpl"
wsdlLocation="wsdl/Ping.wsdl" serviceName="hl7:Ping_Service"
endpointName="hl7:Ping_Port">
</jaxws:endpoint>
“hl7”这里是“urn:hl7-org:v3”命名空间的缩写,PingServiceImpl是实现PingPortType的类。
启动时,CXF记录:
Operation {urn:hl7-org:v3}Ping_PingPong cannot be unwrapped, input message must reference global element declaration with same localname as operation
这很奇怪,因为PingPortType上的@SoapBinding声明parameterStyle应该是BARE,而不是默认的WRAPPED。有些东西忽略/覆盖我的@SoapBinding,但我无法弄清楚是什么。
另外,为什么CXF会将此记录为DEBUG消息?在我看来,ERROR会更合适(并且赞赏......)。