我有一个肥皂客户端,它使用远程肥皂服务。连接和设置一切都很好。当我发送肥皂请求时,我收到如下肥皂故障消息:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Index: 0, Size: 0</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
现在我真的很难理解这样的错误信息。事实上,我知道请求信封一切都很好。谁能帮助我理解这个错误。
这是SOAP请求信封:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:createRequest xmlns:ns2="http://request.services.xyz.com/">
<hid>1234</hid>
<requestTypeCode>APPOINT_REQ</requestTypeCode>
<createdBy>testuser</createdBy>
<assignedTo>testuser</assignedTo>
<data>
<dataField>
<name>ContentText</name>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">Test!</value>
</dataField>
<dataField>
<name>Date</name>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:dateTime">2013-12-09T13:28:34.009-05:00</value>
</dataField>
<dataField>
<name>OrderNumber</name>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">1-123432</value>
</dataField>
</data>
<originAppCode>ABCD</originAppCode>
</ns2:createRequest>
</soap:Body>
</soap:Envelope>
这是我尝试使用SOAP请求调用的方法签名。
public @XmlElement(name="Request")Request createRequest( @WebParam(name="hid")int hid, @WebParam(name="requestTypeCode")String requestTypeCode, @WebParam(name="createdBy")String createdBy,
@WebParam(name="assignedTo")String assignedTo, @WebParam(name="createTime")Date createTime, @WebParam(name="data")DataFields data, @WebParam(name="originAppCode") String originAppCode) throws Exception;
这是wsdl:
的一部分<wsdl:definitions xmlns:ns1="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://request.services.xyz.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="requestServiceImplService" targetNamespace="http://request.services.xyz.com/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://jaxb.dev.java.net/array" version="1.0">
<xs:complexType final="#all" name="stringArray">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:tns="http://request.services.xyz.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="http://request.services.xyz.com/" version="1.0">
<xs:element name="createRequest" type="tns:createRequest"/>
<xs:element name="createRequestResponse" type="tns:createRequestResponse"/>
<xs:element name="dataFields" type="tns:dataFields"/>
<xs:complexType name="createRequest">
<xs:sequence>
<xs:element name="hid" type="xs:int"/>
<xs:element minOccurs="0" name="requestTypeCode" type="xs:string"/>
<xs:element minOccurs="0" name="createdBy" type="xs:string"/>
<xs:element minOccurs="0" name="assignedTo" type="xs:string"/>
<xs:element minOccurs="0" name="createTime" type="xs:dateTime"/>
<xs:element minOccurs="0" name="data" type="tns:dataFields"/>
<xs:element minOccurs="0" name="originAppCode" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="createRequestResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:request"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="dataFields">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="dataField" type="tns:dataField"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="dataField">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="value" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="createRequest">
<wsdl:part element="tns:createRequest" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="createRequestResponse">
<wsdl:part element="tns:createRequestResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:operation name="createRequest">
<wsdl:input message="tns:createRequest" name="createRequest"></wsdl:input>
<wsdl:output message="tns:createRequestResponse" name="createRequestResponse"> </wsdl:output>
</wsdl:operation>
<wsdl:binding name="RequestServiceImplServiceSoapBinding" type="tns:IRequestService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="createRequest">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="createRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="createRequestResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RequestServiceImplService">
<wsdl:port binding="tns:RequestServiceImplServiceSoapBinding" name="RequestServiceImplPort">
<soap:address location="location_where_service_is_being_hosted/cxf/jaxws/RequestService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
答案 0 :(得分:2)
Index: 0, Size: 0
等消息通常由IndexOutOfBoundsException
s。
在你的情况下,这可能意味着:
IndexOutOfBoundsException
。后续步骤:
检查您的服务器是否接受来自SoapUI的请求。
结果: 使用SoapUI时也会出现此错误。
XML / XML架构
XML和XML Schema中的一些内容引起了我的注意。
createRequest
使用命名空间。其他元素没有命名空间,因为它们没有指定命名空间前缀。使用<createRequest xmlns="http://request.services.xyz.com/">
会为createRequest
以下的所有元素分配默认命名空间。type="tns:dataFields"
的引用,尽管只有dataField
。createRequest
是小写的,而在请求中它是用camel case编写的。我假设两者都是不是真正的问题,因为您更改了StackOverflow的名称。)服务器错误
由于无法发送服务器接受的任何请求(甚至不使用SoapUI),因此您必须调试服务器。
java.lang.Exception
上设置一个断点,并将其缩小,直到找到问题为止。