faultCode argument for createFault was passed NULL

2019-08-03 04:24发布

I am using Metro 2.3 and invoking webservice request using JAX-WS. As part of the one of the flow, we are getting faultResponse, but while handling that I am getting the below exception

java.lang.IllegalArgumentException: faultCode argument for createFault was passed NULL
   at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl.createFault(SOAPFactory1_1Impl.java:68)
   at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:184)
   at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:125)
   at com.sun.xml.ws.client.sei.StubHandler.readResponse(StubHandler.java:253)
   at com.sun.xml.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:181)
   at com.sun.xml.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:258)
   at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:117)
   at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)
   at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)...

From tcpdump, this is the response we are getting back,

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<SOAP-ENV:faultcode>SOAP-ENV:Client</SOAP-ENV:faultcode>
<SOAP-ENV:faultstring>Not logged in. Request rejected</SOAP-ENV:faultstring>
<SOAP-ENV:detail>
<res:Error xmlns:res="http://www.xtcplus.com/soap/schemas/requests/fault/tfcsoap-fault">
<ErrorNo>30001</ErrorNo>
<TextID>10022</TextID>
<Text>Not logged in. Request rejected</Text>
<Level>5</Level>
<SubsystemID>0</SubsystemID>
</res:Error>
</SOAP-ENV:detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I went through other forums and suspect this could be some namesapce issue. So. I just simulated the response from SOAP UI for different combinations and the below response works fine. The system is able to parse it properly and displayed the error response.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>Client</faultcode>
<faultstring>Not logged in. Request rejected</faultstring>
<SOAP-ENV:detail>
<res:Error xmlns:res="http://www.xtcplus.com/soap/schemas/requests/fault/tfcsoap-fault">
<ErrorNo>30001</ErrorNo>
<TextID>10022</TextID>
<Text>Not logged in. Request rejected</Text>
<Level>5</Level>
<SubsystemID>0</SubsystemID>
</res:Error>
</SOAP-ENV:detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Basically I removed, "SOAP-ENV" from "faultcode" and "faultstring" xml tags. I am new to this XML part and finding it difficult what is really the problem here. I have even went through this link reg. faultResponse spec. http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383510. But still I am not very clear as I am new to this. This reponse comes to me from a 3rd party system. Is it that the reponse is not complaint to the standards ? Could you please help me to find the reason for this behavior ?

1条回答
爷的心禁止访问
2楼-- · 2019-08-03 05:05

Ok. I have found out the reason after going through the SOAP Fault code schema. http://schemas.xmlsoap.org/soap/envelope/

As per this, the name space should not be prefixed for "faultcode" and "faultstring".

<xs:element name="faultcode" type="xs:QName"/>
<xs:element name="faultstring" type="xs:string"/>

Whereas tags like "Fault" should be prefixed with namespace

<xs:element name="Fault" type="tns:Fault"/>
查看更多
登录 后发表回答