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:
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" );
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?
Is the service within a SEQUENCE at all? If so, what is the EXIT ON value?
It is not necessary to write a java service to return a customized soap fault. See this thread for details.
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!
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:
The input XML did not pass schema validation.
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.
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:
<faultstring>The input XML did not pass schema validation.</faultstring>
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”>
We have received invalid XML
/VehicleStatusUpdateRequest/CurrentStatus/EngineStatus||[ISC.0082.9460] No matching enumeration value