我正在构建一个服务来接受以下消息。注意 InformationExchangePackage 没有命名空间前缀,而是采用默认的 xmlns="http://www.something.com/dir/1.0.9"。我不知道如何在 WSDL 中创建这种行为。
我要服务的 SOAP 请求:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<InformationExchangePackage xmlns:j="http://www.something.gov/dir/3.0.3" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://www.something.com/dir/1.0.9">
<j:OtherInformation>Sometext</OtherInformation>
</InformationExchangePackage>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
以下是soapUI 生成的SOAP 请求。注意 InformationExchangePackage 上的“loc”前缀(不是我想要的)。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:loc="http://localhost/">
<soapenv:Header/>
<soapenv:Body>
<loc:process>
<loc:InformationExchangePackage>
<OtherInformation>?</OtherInformation>
</loc:InformationExchangePackage>
</loc:process>
</soapenv:Body>
</soapenv:Envelope>
我当前的 WSDL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://localhost/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:cs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://localhost/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<wsdl:types>
<xs:schema targetNamespace="http://localhost/">
<xs:element name="InformationExchangePackage">
<xs:complexType>
<xs:sequence>
<xs:element name="OtherInformation" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="processResponseType">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="aCode"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="processRequest">
<wsdl:part name="InformationExchangePackage" element="tns:InformationExchangePackage"/>
</wsdl:message>
<wsdl:message name="processResponse">
<wsdl:part name="processResponse" element="tns:processResponseType"/>
</wsdl:message>
<wsdl:portType name="CCHEndpoint">
<wsdl:operation name="process">
<wsdl:input message="tns:processRequest"/>
<wsdl:output message="tns:processResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CCHBinding" type="tns:CCHEndpoint">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="process">
<soap:operation soapAction="urn:process" style="rpc"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CCHEndpointService">
<wsdl:port name="OrderService" binding="tns:CCHBinding">
<!--<soap:address location="http://localhost:8080/wildcat"/>-->
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
如果我使用 loc 前缀提交请求,它就可以工作。如果我提交没有 loc 前缀的请求,我会得到:
org.apache.cxf.interceptor.Fault: Message part {http://www.something.com/dir/1.0.9}InformationExchangePackage was not recognized. (Does it exist in service WSDL?)
我想我在 WSDL 中缺少一个参数。我在黑暗中拍摄了以下照片,但无济于事:
<xs:element name="InformationExchangePackage" xsi:schemaLocation="http://www.something.com/dir/1.0.9">
<xs:element name="InformationExchangePackage" xsi:noNamespaceSchemaLocation="http://www.something.com/dir/1.0.9">