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:
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]
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?
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).
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:
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
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>