我从 WSDL 文件为我正在处理的项目自动生成了一个解决方案,但由于某种原因,该解决方案似乎无法正确处理 WSDL 指定的输入。有谁知道我能做些什么来修复它?
给定以下操作:
<wsdl:operation name="createBin">
<wsdl:input message="impl:createBinRequest" name="createBinRequest"/>
<wsdl:output message="impl:createBinResponse" name="createBinResponse"/>
</wsdl:operation>
<wsdl:message name="createBinRequest">
<wsdl:part element="impl:createBin" name="parameters"/>
</wsdl:message>
<element name="createBin">
<complexType>
<sequence>
<element name="request" type="impl:Bin"/>
</sequence>
</complexType>
</element>
<complexType name="Bin">
<sequence>
<element name="FulfillerID" type="xsd:positiveInteger"/>
<element name="BinID" nillable="true" type="xsd:positiveInteger"/>
<element name="ExternalLocationID" type="xsd:string"/>
<element name="BinType" type="xsd:string"/>
<element name="BinStatus" type="xsd:string"/>
<element name="Name" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
使用此代码实现(由 eclipse 自动生成):
public PositiveInteger createBin(Bin request) throws RemoteException {
throw new UnsupportedOperationException();
}
发送此消息时:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://my.api.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:createBin>
<q0:request>
<q0:FulfillerID>1234</q0:FulfillerID>
<q0:BinID>1234</q0:BinID>
<q0:ExternalLocationID>1234</q0:ExternalLocationID>
<q0:BinType>Good</q0:BinType>
<q0:BinStatus>Bad</q0:BinStatus>
<q0:Name>Ugly</q0:Name>
</q0:request>
</q0:createBin>
</soapenv:Body>
</soapenv:Envelope>
我收到以下错误:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXException: Invalid element in com.api.my.Bin - request</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">localhost</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
我 100% 确定 SOAP 消息的格式是正确的,所以我的服务器一定是因为某些东西而窒息。当我删除参数时,由于某种原因,一切都正常运行。
但是,我可以通过像这样删除元素来获得预期的行为:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://my.api.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:createBin>
<q0:FulfillerID>1234</q0:FulfillerID>
<q0:BinID>1234</q0:BinID>
<q0:ExternalLocationID>1234</q0:ExternalLocationID>
<q0:BinType>Good</q0:BinType>
<q0:BinStatus>Bad</q0:BinStatus>
<q0:Name>Ugly</q0:Name>
</q0:createBin>
</soapenv:Body>
</soapenv:Envelope>