• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

faultCode argument for createFault was passed NULL

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting the following exception intermittently when the web service returns a fault.

faultCode argument for createFault was passed NULL
com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl.createFault(SOAPFactory1_1Impl.java:87)
com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:179)
com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:108)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)

I found the following link and it looks like a JAX-WS bug.

http://forums.java.net/node/675759

So, I added the following code in my client side handler.

public boolean handleFault(SOAPMessageContext smc) {

logger.info("Inside handleFault");
SOAPMessage message = smc.getMessage();
logger.info("Inbound SOAP Message with Fault: ");
printSOAPMessageToLogger(message);

try{
QName fqn = message.getSOAPBody().getFault().getFaultCodeAsQName();
String namespace = fqn.getNamespaceURI();

logger.info("fault namespace: " + namespace);

if (namespace == null || namespace.length() == 0){
logger.info("missing namespace in soap fault: " );
namespace = "http://schemas.xmlsoap.org/soap/envelope/";
QName newFqn = new QName(namespace , fqn.getLocalPart());
smc.getMessage().getSOAPBody().getFault().setFaultCode(newFqn);
}
}catch (Exception ex) {
logger.error("Cannot modify Soap Fault: " , ex);
}

return true;
}


I have 2 questions.

1) In the above code, is it correct to set the fault namespace to http://schemas.xmlsoap.org/soap/envelope/? I read it somewhere else that SOAP fault should have an empty namespace. Is this correct?

2) I am getting a NullPointerException in the line that has the code when fault is returned by the web service.

message.getSOAPBody().getFault().getFaultCodeAsQName();

I would appreciate if someone can help me. Thanks in advance.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic