2013-12-10 81 views
1

我有一个使用远程肥皂服务的肥皂客户端。连接和设置一切正常。当我发送SOAP请求,我得到一个SOAP错误消息如下:获得肥皂:消耗肥皂服务时发生故障

<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

您能否粘贴您要发送的请求 –

+0

我刚刚编辑了问题并将其添加到上面。对不起,以前没有添加它。 – Ashish

+0

@Ashish,你还可以检查你在服务器端获得的所有例外情况。 –

回答

2

消息像Index: 0, Size: 0常常是由于IndexOutOfBoundsException秒。

在你这可能意味着情况:

  • 的要求是空的。
  • 该请求具有错误的编码。
  • 安全机制不会让你的请求通过。
  • 后台有一个IndexOutOfBoundsException

下一个步骤:如果您的服务器接受来自SoapUI请求

检查。

  • 您可以完全控制请求,所以如果出现问题,可能是后端错误。
  • 如果有效,客户端存在问题。检查你的客户发送的请求。它是否完整?它是否包含无法读取的字符?

结果:使用了SoapUI时也会发生错误。

XML/XML模式

在XML有些东西和XML Schema吸引了我的注意。

  • 仅在请求createRequest使用命名空间。其他元素没有名称空间,因为它们没有指定名称空间前缀。使用<createRequest xmlns="http://request.services.xyz.com/">会为createRequest以下的所有元素分配默认名称空间。
  • (在XML Schema中有对type="tns:dataFields"的引用,尽管只有dataField。另外createRequest是小写,而在请求中它是用骆驼事件写的。我认为这两种都不是真正的问题,因为你改变了名字的StackOverflow。)

Server错误

因为它是不可能通过发送服务器接受的请求(即使不是了SoapUI),你明确地必须调试服务器。

  • 日志中是否有任何错误消息?
  • 异常发生在哪里?在java.lang.Exception上设置一个断点并缩小直到找到问题。
+0

做soap:服务器意味着错误来自服务器端。只是为了说明,该服务在其后端访问数据库。我尝试了与SoapUI相同的请求信封,但我得到了同样的错误。 – Ashish

+0

我很抱歉混淆,那些是我的错误。我刚刚编辑了wsdl,以免让人感到困惑。我查看了服务器日志。我发现有同样的错误“IndexOutOfBoundException”。谢谢 – Ashish

+0

嗨,我能弄清楚这个问题。我在SOAP请求中发送的“requestTypeCode”的值在数据库中不存在,并且由于该typeCode无法映射到Database表中的任何值,因此它发送了IndexOutOfBound异常。非常感谢您帮助我调试问题。 – Ashish