IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  throwCustomSOAPException

    Posted 03/21/07 03:17 PM

    Hello, This is my first post. I am not sure if this is the right forum, but I am having trouble within webMethods IS when trying to throw my own custom SOAP fault.

    [SIZE=2]I am creating a SOAP service and want to create my own SOAP fault when a schema fails validation instead of throwing the regular wM SOAP fault that has a FaultCode of Server and a generic faultString stating exception while processing flow.

    I am following the Gear 6.5 best practices which says “In order to throw a custom error message exception from the Integration Server, the flow service needs to invoke a Java service that throws a SOAP exception. The following code example shows the content of the Java service [/size]throwSoapException[SIZE=2]”.
    I have created the custom java service that it describes:

     // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    String faultCode = IDataUtil.getString( pipelineCursor, "faultCode" );
    String faultString = IDataUtil.getString( pipelineCursor, "faultString" );
    String faultActor = IDataUtil.getString( pipelineCursor, "faultActor" );
    String faultDetail = IDataUtil.getString( pipelineCursor, "faultDetail" );
    String qualifyFaultCodeVal = IDataUtil.getString( pipelineCursor, "qualifyFaultCodeVal" );
    pipelineCursor.destroy();
    Boolean qualifyFaultCode = Boolean.valueOf( qualifyFaultCodeVal );
    throw new SOAPException( faultCode, faultString, faultActor, faultDetail, qualifyFaultCode.booleanValue() );

    The java service has compiled successfully but when I run the flow and I get to the call of the throwSoapException code, it always executes the next step after this service. I was assuming that it would automatically throw a SOAP Fault and exit the flow. It is not clear to me if I am missing a step.

    Also please note that my service is not within a Try/Catch block. I notice within the Web Services best practices doc it does say that there is an extra step you need to do in order to throw an exception within the Catch Block, otherwise it executes the next step of the code. However I am not in a Try or catch block, so I don’t think that relates to what I am doing.

    I am using Integration server: 6.5 service pack 2
    I am sure someone will have an easy answer for me. Can anyone help?
    [/size]


    #webMethods
    #API-Management
    #soa


  • 2.  RE: throwCustomSOAPException

    Posted 03/21/07 08:02 PM

    Is the service within a SEQUENCE at all? If so, what is the EXIT ON value?


    #API-Management
    #soa
    #webMethods


  • 3.  RE: throwCustomSOAPException

    Posted 03/21/07 08:23 PM

    It is not necessary to write a java service to return a customized soap fault. See this thread for details.

    Mark


    #soa
    #API-Management
    #webMethods


  • 4.  RE: throwCustomSOAPException

    Posted 03/21/07 10:30 PM

    Mark,

    Thank you very much. I was able to follow your instructions. I had seen that thread before, but I saw the throwSoapException java service in the gear web Services best practices documentation and I thought that was the recommended route. I’d prefer your way, though. I appreciate your help. I haven’t quite completed it though. I am receiving an error at the very last step when I addBodyEntry to my soapResponseData. It says “Invalid Body Entry. SOAP body entries must have a namespace name.”

    I’m sure I need SOAP-ENV in there somewhere, but can you tell me the best way to resolve this error?

    Thanks, so much!
    Sara


    #soa
    #API-Management
    #webMethods


  • 5.  RE: throwCustomSOAPException

    Posted 03/22/07 12:07 AM

    You need to populate the nsDecls parameter on your pub.xml:DocumentToXMLString invoke with the prefix SOAP-ENV and the namespace for the soap envelope (found in an empty message created with pub.soap.utils:createSoapData).

    Mark


    #soa
    #API-Management
    #webMethods


  • 6.  RE: throwCustomSOAPException

    Posted 03/22/07 01:44 PM

    Hi Scott,

    I actually had that parameter set already, but I am still seeing that error. After I populate my SOAP-FAULT document, I have the XMLDocumentToString step. I have set the nsDecls prameter so that the namespace prefix is SOAP-ENV which resolves to [URL=“http://schemas.xmlsoap.org/soap/envelope/”]http://schemas.xmlsoap.org/soap/envelope/[/URL]. I also have the documentTypeName set to the path where the SOAP-FAULT documnt exists within webMethods (I even tried it without populating this parameter, but the result was the same). The xmlstring that is created from this step looks like this:

    <?xml version="1.0"?>

    <SOAP-FAULT
    xmlns:SOAP-ENV=“[URL=“http://schemas.xmlsoap.org/soap/envelope/”]http://schemas.xmlsoap.org/soap/envelope/[/URL]”>
    Client
    The input XML did not pass schema validation.
    http://ZZ/soap/VehicleStatusUpdateRequest

    I then do a XMLStringToNode, passing in the xmldata and setting isXML to true. I then createSoapData and set the output to the soapResponseData.

    The last step I do is addBodyEntry, where I map the soapResponseData into the “soapData” parameter and the node from the SOAP-FAULT document into “bodyEntry” parameter.

    When I run this, I still get the following error:

    “Invalid BodyEntries. SOAP Body entries must have a namespace name.”

    I appreciate any help you can provide.
    Thanks,
    Sara


    #soa
    #API-Management
    #webMethods


  • 7.  RE: throwCustomSOAPException

    Posted 03/22/07 09:01 PM

    Your document needs to have the prefix “SOAP-ENV” added to the SOAP-FAULT element. Do this by renaming the document to “SOAP-ENV:SOAP-FAULT” prior to making the pub.xml:xmlDocumentToString call.

    The resulting document should be:

     <?xml version="1.0"?>
    <SOAP-ENV:SOAP-FAULT
    xmlns:SOAP-ENV="[URL="http://schemas.xmlsoap.org/soap/envelope/"]http://schemas.xmlsoap.org/soap/envelope/[/URL]">
    <faultcode>Client</faultcode>
    <faultstring>The input XML did not pass schema validation.</faultstring>
    <faultactor>http://ZZ/soap/VehicleStatusUpdateRequest</faultactor>
    </SOAP-ENV:SOAP-FAULT>

    Mark


    #webMethods
    #API-Management
    #soa


  • 8.  RE: throwCustomSOAPException

    Posted 03/22/07 10:51 PM

    Thank you Mark (sorry I called you Scott before),

    I ended up creating my own xsd and importing it so that I would have a SOAP-FAULT document where the root element was namespace qualified.

    The SOAP FAULT that I returned is copied below. It might be a bit overkill. Do you think it matters? Thanks for all of your help!

    <SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:SOAP-ENC=“http://schemas.xmlsoap.org/soap/encoding/” xmlns:xsd=“XML Schema” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
    [SIZE=2][COLOR=#0000ff]-[/color][/size] SOAP-ENV:Body
    [SIZE=2][COLOR=#0000ff]-[/color][/size] SOAP-ENV:SOAP-FAULT
    Sender
    We have received invalid XML
    http://ZZ/soap/VehicleStatusUpdateRequest
    [SIZE=2][COLOR=#0000ff]-[/color][/size]
    Validation Error
    /VehicleStatusUpdateRequest/CurrentStatus/EngineStatus||[ISC.0082.9460] No matching enumeration value

    </SOAP-ENV:SOAP-FAULT>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


    #soa
    #webMethods
    #API-Management