Author |
Message
|
oli |
Posted: Mon Jul 11, 2011 4:48 am Post subject: Creating a SOAP Fault |
|
|
Acolyte
Joined: 14 Jul 2006 Posts: 68 Location: Germany
|
Hi all,
I have a message flow that acts a a web service gateway using SOAPInput, SOAPRequest and SOAPReply nodes. Before sending the request out a Java plugin node does some validation on the incoming SOAP request message. If this validation fails I have to reply a SOAP fault message. How can I achieve this? Can broker generate such (user-defined) fault messages that can be sent to the SOAPReply node?
Thanks,
Oli |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Jul 11, 2011 5:00 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
j.f.sorge |
Posted: Mon Jul 11, 2011 5:02 am Post subject: |
|
|
Master
Joined: 27 Feb 2008 Posts: 218
|
I have used HTTP Reply Node with SOAP Envelop to sent my own Failure messages. These message will be created using ESQL code and you may create them within your Java validation node, too. _________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
oli |
Posted: Tue Jul 12, 2011 12:04 am Post subject: |
|
|
Acolyte
Joined: 14 Jul 2006 Posts: 68 Location: Germany
|
First thanks for the replies
@lancelotlinc
I took a look at the 4 parts of that tutorial but I couldn't find a concrete hint how to create a fault response. The only hint that I found was that if an exception occurs and the catch terminal is not connected then broker replies a fault. Is that correct? If I want to throw an exception in my Java plugin node I have to use a subclass of MbException if this is allowed to.
@j.f.sorge
That's exactly what I want to do if there's no chance to let broker build the fault response automatically. At the moment it's not clear to me how to handle the HTTP Headers, Message properties etc. before sending the message to the SOAPReply node.
Further tips are still appreciated
Oli |
|
Back to top |
|
 |
j.f.sorge |
Posted: Tue Jul 12, 2011 12:20 am Post subject: |
|
|
Master
Joined: 27 Feb 2008 Posts: 218
|
oli wrote: |
I took a look at the 4 parts of that tutorial but I couldn't find a concrete hint how to create a fault response. The only hint that I found was that if an exception occurs and the catch terminal is not connected then broker replies a fault. Is that correct? If I want to throw an exception in my Java plugin node I have to use a subclass of MbException if this is allowed to. |
This will be the easiest way to implement it. Throw a MbUserException and add the validation error into its Object[]. _________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
oli |
Posted: Tue Jul 12, 2011 11:45 pm Post subject: |
|
|
Acolyte
Joined: 14 Jul 2006 Posts: 68 Location: Germany
|
Now I have tried to throw an MbUserException but that doesn't fulfill the requirements. So I think I have to create the SOAP fault response manually. Creating the SOAP message itself seems not to be the problem. But at the moment it's completely unclear to me what else must be done before sending the message to the SOAPReply node regarding HTTP Headers, message properties, etc.
Can anybody explain how a SOAP reply message can be build from scratch or give me a hint where to find information about that?
Thanks again,
Oli |
|
Back to top |
|
 |
j.f.sorge |
Posted: Wed Jul 13, 2011 12:02 am Post subject: |
|
|
Master
Joined: 27 Feb 2008 Posts: 218
|
When using the MRM domain you may import the SOAP definition directly.
In ESQL you may create the message with the following code.
Code: |
CALL CopyMessageHeaders();
DECLARE ns NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
SET OutputRoot.Properties.MessageSet = 'MessageSet';
SET OutputRoot.Properties.MessageType = 'MessageType';
SET OutputRoot.Properties.MessageFormat = 'MessageFormat';
DECLARE ref_out REFERENCE TO OutputRoot;
CREATE LASTCHILD OF OutputRoot AS ref_out DOMAIN 'MRM' NAME 'MRM';
SET ref_out.ns:Body.ns:Fault.faultcode = 'FaultCode';
SET ref_out.ns:Body.ns:Fault.faultstring= 'FaultString';
SET ref_out.ns:Body.ns:Fault.faultactor = InputRoot.HTTPInputHeader."X-Original-HTTP-Command";
SET ref_out.ns:Body.ns:Fault.detail.Text = 'DetailText';
-- status code must be an error code, otherwise Fault message will not be parsed on receiver
SET OutputLocalEnvironment.Destination.HTTP.ReplyStatusCode = 500; |
_________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
oli |
Posted: Wed Jul 13, 2011 12:52 am Post subject: |
|
|
Acolyte
Joined: 14 Jul 2006 Posts: 68 Location: Germany
|
Unfortunately I'm not very familiar using the MRM domain. So what do you mean with "you may import the SOAP definition directly"?
Can I achieve the same behaviour using the XMLNSC domain in a Compute Node or - even better - cretae the SOAP Fault message directly within my Java Plugin Node?
Thanks,
Oli |
|
Back to top |
|
 |
j.f.sorge |
Posted: Wed Jul 13, 2011 1:02 am Post subject: |
|
|
Master
Joined: 27 Feb 2008 Posts: 218
|
oli wrote: |
Unfortunately I'm not very familiar using the MRM domain. So what do you mean with "you may import the SOAP definition directly"?
Can I achieve the same behaviour using the XMLNSC domain in a Compute Node or - even better - cretae the SOAP Fault message directly within my Java Plugin Node?
Thanks,
Oli |
You may create it within the JCN but you'll have to code it yourself. _________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
oli |
Posted: Wed Jul 13, 2011 2:22 am Post subject: |
|
|
Acolyte
Joined: 14 Jul 2006 Posts: 68 Location: Germany
|
In a first step I'd like to use a Compute Node but I still cannot reply a SOAP fault using the SOAPReply node for some reason. I currently use the following ESQL code:
Code: |
CALL CopyMessageHeaders();
DECLARE ref_out REFERENCE TO OutputRoot;
CREATE LASTCHILD OF OutputRoot AS ref_out DOMAIN 'SOAP' NAME 'SOAP';
SET ref_out.Body.Fault.Code.Value = 'MyFault';
SET ref_out.Body.Fault.Reason.Text = 'A validation exception occured';
-- status code must be an error code, otherwise Fault message will not be parsed on receiver
SET OutputLocalEnvironment.Destination.HTTP.ReplyStatusCode = 400;
|
The SOAPReply node then throws an exception so that the requestor gets a SOAP fault with the following text:
Code: |
BIP3752E: The SOAP Reply node 'com.daimler.iap.bib.showcase.PassThruValidateFlowSoap.SOAP Reply' encountered an error while processing a reply message.
An error occurred during reply message processing.
See previous error messages to determine the cause of the error. : F:\build\S700_P\src\WebServices\WSLibrary\ImbSOAPReplyNode.cpp: 346: ImbSOAPReplyNode::evaluate: ComIbmSOAPReplyNode: com/daimler/iap/bib/showcase/PassThruValidateFlowSoap#FCMComposite_1_11
BIP3605E: The SOAP logical tree cannot be serialized.
There is a problem with the SOAP logical tree format.
Review further error messages for an indication to the cause of the error. Check that the SOAP logical supplied is correctly formatted. : F:\build\S700_P\src\WebServices\WSLibrary\ImbSOAPParser.cpp: 1217: ImbSOAPParser::refreshBitStreamFromElementsInner: :
BIP3602E: The Web service payload ''{}Fault'' does not match an operation described by WSDL binding ''soap12PortBinding'' in file ''c:\pai\wmb\working\components\NSPZ001I\a7590f65-3001-0000-0080-d5144a91d086\config\XSD\ESIShowcaseMessageSet/daimler/iapcisservicev1/cis.wsdl''.
The first child of the SOAP Body does not correspond to any of the operations defined in the specified WSDL definition.
Check that the correct WSDL definition was deployed. : F:\build\S700_P\src\WebServices\WSLibrary\ImbSOAPParser.cpp: 701: ImbSOAPParser::refreshBitStreamFromElementsInner: :
|
Any ideas what to do?
Thanks,
Oli |
|
Back to top |
|
 |
mgk |
Posted: Wed Jul 13, 2011 3:21 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Hi, Here is some code to create a SOAP complete 1.2 Fault message for the SOAP Domain:
Code: |
DECLARE soapenv NAMESPACE 'http://www.w3.org/2003/05/soap-envelope';
DECLARE xml NAMESPACE 'http://www.w3.org/XML/1998/namespace';
DECLARE my NAMESPACE 'http://mgk';
SET OutputRoot.SOAP.Context.Namespace.(SOAP.NamespaceDecl)xmlns:soapenv = soapenv;
SET OutputRoot.SOAP.Context.Namespace.(SOAP.NamespaceDecl)xmlns:my = my;
SET OutputRoot.SOAP.Body.soapenv:Fault.soapenv:Code.soapenv:Value = 'soapenv:Receiver';
SET OutputRoot.SOAP.Body.soapenv:Fault.soapenv:Code.soapenv:Subcode.soapenv:Value = 'my:subcode value';
SET OutputRoot.SOAP.Body.soapenv:Fault.soapenv:Reason.soapenv:Text = 'my Reason string';
SET OutputRoot.SOAP.Body.soapenv:Fault.soapenv:Reason.soapenv:Text.(SOAP.Attribute)xml:lang = 'en';
SET OutputRoot.SOAP.Body.soapenv:Fault.soapenv:Node = 'my Node string';
SET OutputRoot.SOAP.Body.soapenv:Fault.soapenv:Role = 'my Role string';
SET OutputRoot.SOAP.Body.soapenv:Fault.soapenv:Detail.my:Text = 'my detail string'; |
Depending on the fix pac you are on, the SOAPReply node will also detect a fault is being sent and set the status code to 500 automatically. However, if you want a different value, then the field to set for the SOAP nodes is:
Code: |
SET OutputLocalEnvironment.Destination.SOAP.Reply.Transport.HTTP.ReplyStatusCode = 552; |
I hope this helps, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
oli |
Posted: Wed Jul 13, 2011 3:49 am Post subject: |
|
|
Acolyte
Joined: 14 Jul 2006 Posts: 68 Location: Germany
|
Hi MGK,
thanks a lot, it work's
The code's a good base for me to do further development.
Oli |
|
Back to top |
|
 |
bharathkumar |
Posted: Mon Jan 30, 2012 5:26 am Post subject: |
|
|
Newbie
Joined: 30 Jan 2012 Posts: 1
|
HI MGK,
I tried your code, but am still getting the same error, Please let me know if have to do anything...
" The SOAP logical tree cannot be serialized.
There is a problem with the SOAP logical tree format. "
Thnks
Bharath |
|
Back to top |
|
 |
kimbert |
Posted: Tue Jan 31, 2012 12:54 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
j.f.sorge said:
Quote: |
When using the MRM domain you may import the SOAP definition directly. |
But please don't. Since v6.1 the MRM domain is not for SOAP or XML. There are much better ways to do the job. |
|
Back to top |
|
 |
|