Author |
Message
|
hornbeam123 |
Posted: Mon Jun 16, 2008 11:17 am Post subject: SOAP navigation XMLNS |
|
|
Centurion
Joined: 01 Nov 2003 Posts: 101
|
I have this soap response to analyse.
<ns1:updateCostCentreResponse><costCentreUpdateResponse xsi:type="ns1:UpdateResponse">
<ValidationError xsi:type="ns1:ValidationError">
<ErrorTypeCode xsi:type="ns1:ErrorTypeCode">06</ErrorTypeCode>
<ErrorMessage xsi:type="xsd:string">Cost center creation successful</ErrorMessage>
</ValidationError>
</costCentreUpdateResponse></ns1:updateCostCentreResponse>
What is the most eloquent way to navigate to the fields highlighted?
I tried various combinations starting InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse
DECLARE myNS2 NAMESPACE 'a url';
but none seem to work.
Any ideas please? |
|
Back to top |
|
 |
elvis_gn |
Posted: Mon Jun 16, 2008 9:04 pm Post subject: Re: SOAP navigation XMLNS |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi hornbeam123,
hornbeam123 wrote: |
<ns1:updateCostCentreResponse><costCentreUpdateResponse xsi:type="ns1:UpdateResponse">
<ValidationError xsi:type="ns1:ValidationError">
<ErrorTypeCode xsi:type="ns1:ErrorTypeCode">06</ErrorTypeCode>
<ErrorMessage xsi:type="xsd:string">Cost center creation successful</ErrorMessage>
</ValidationError>
</costCentreUpdateResponse></ns1:updateCostCentreResponse> |
Code: |
DECLARE mySoapNS NAMESPACE 'soap url';
DECLARE myNS2 NAMESPACE 'a url';
InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ErrorTypeCode
InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ErrorMessage
|
The above will not work IF you have a default namespace defined somewhere in the parent elements...default namespace being xmlns="some url" (there won't be a prefix, i.e xmlns:ns1)
Regards. |
|
Back to top |
|
 |
hornbeam123 |
Posted: Tue Jun 17, 2008 2:04 am Post subject: SOAP navigation XMLNS |
|
|
Centurion
Joined: 01 Nov 2003 Posts: 101
|
The full SOAP message is below. It normally comes back as a response to HTTPRequest. In the WS client flow I save the full response to a msg on an audit q. This I have copied pasted to a test flow to get the response handling code working.
I have tried about dozen lines of code now nothing works.
e.g. SET somevar3 = InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorMessage ;
Should I download that strip namespaces code? Or parse as string or blob !
I note a default namespace is not included in the soap.
This is very frustrating, if this was simple XML, could have coded this in seconds.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://ACOMPANY.co.uk/StoreCollection"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:updateCostCentreResponse><costCentreUpdateResponse xsi:type="ns1:UpdateResponse">
<ValidationError xsi:type="ns1:ValidationError">
<ErrorTypeCode xsi:type="ns1:ErrorTypeCode">06</ErrorTypeCode>
<ErrorMessage xsi:type="xsd:string">Cost center creation successful</ErrorMessage>
</ValidationError></costCentreUpdateResponse></ns1:updateCostCentreResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> |
|
Back to top |
|
 |
mgk |
Posted: Tue Jun 17, 2008 2:11 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Hi, Can you paste the output of a trace node showing $Root for this message. It will let you know what WMB believes your namespaces are etc... _________________ 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 |
|
 |
hornbeam123 |
Posted: Tue Jun 17, 2008 8:50 am Post subject: SOAP navigation XMLNS |
|
|
Centurion
Joined: 01 Nov 2003 Posts: 101
|
Here you go.
(0x01000000):HTTPResponseHeader = (
(0x03000000):X-Original-HTTP-Status-Line = 'HTTP/1.1 200 OK'
(0x03000000):X-Original-HTTP-Status-Code = 200
(0x03000000):Date = 'Thu, 12 Jun 2008 21:38:54 GMT'
(0x03000000):Server = 'Apache'
(0x03000000):X-Powered-By = 'PHP/5.2.0-8+etch10'
(0x03000000):Content-Length = '794'
(0x03000000):Connection = 'close'
(0x03000000):Content-Type = 'text/xml; charset=UTF-8'
)
(0x01000010):XMLNS = (
(0x05000018):XML = (
(0x06000011): = '1.0'
(0x06000012): = 'UTF-8'
)
(0x06000002): = '
'
(0x01000000)http://schemas.xmlsoap.org/soap/envelope/:Envelope = (
(0x07000012)xmlns:SOAP-ENV = 'http://schemas.xmlsoap.org/soap/envelope/'
(0x07000012)xmlns:ns1 = 'http://aGreatCompany.co.uk/StoreCollection'
(0x07000012)xmlns:xsd = 'http://www.w3.org/2001/XMLSchema'
(0x07000012)xmlns:xsi = 'http://www.w3.org/2001/XMLSchema-instance'
(0x07000012)xmlns:SOAP-ENC = 'http://schemas.xmlsoap.org/soap/encoding/'
(0x03000000)http://schemas.xmlsoap.org/soap/envelope/:encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'
(0x01000000)http://schemas.xmlsoap.org/soap/envelope/:Body = (
(0x01000000)http://aGreatCompany.co.uk/StoreCollection:updateCostCentreResponse = (
(0x01000000):costCentreUpdateResponse = (
(0x03000000)http://www.w3.org/2001/XMLSchema-instance:type = 'ns1:UpdateResponse'
(0x01000000):ValidationError = (
(0x03000000)http://www.w3.org/2001/XMLSchema-instance:type = 'ns1:ValidationError'
(0x01000000):ErrorTypeCode = (
(0x03000000)http://www.w3.org/2001/XMLSchema-instance:type = 'ns1:ErrorTypeCode'
(0x02000000): = '07'
)
(0x01000000):ErrorMessage = (
(0x03000000)http://www.w3.org/2001/XMLSchema-instance:type = 'xsd:string'
(0x02000000): = 'Cost center Update successful'
)
)
)
)
)
)
(0x06000002):  |
|
Back to top |
|
 |
mgk |
Posted: Tue Jun 17, 2008 1:53 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
According to the trace you seem to be missing the ValidationError element from your path _________________ 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 |
|
 |
hornbeam123 |
Posted: Tue Jun 17, 2008 2:22 pm Post subject: SOAP navigation XMLNS |
|
|
Centurion
Joined: 01 Nov 2003 Posts: 101
|
Hi MGK that element was on my second example.
e.g. SET somevar3 = InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorMessage ;
 |
|
Back to top |
|
 |
mgk |
Posted: Wed Jun 18, 2008 1:15 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
OK, I missed your second example.
Can you post your actual ESQL, showing your namespace declarations in full as the path seems correct, so maybe one of your namespace declarations is not quite right?
Cheers, _________________ 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 |
|
 |
hornbeam123 |
Posted: Wed Jun 18, 2008 2:35 am Post subject: SOAP navigation XMLNS |
|
|
Centurion
Joined: 01 Nov 2003 Posts: 101
|
MGK will provide this esql as soon as I can. |
|
Back to top |
|
 |
hornbeam123 |
Posted: Wed Jun 18, 2008 4:31 am Post subject: SOAP navigation XMLNS |
|
|
Centurion
Joined: 01 Nov 2003 Posts: 101
|
The complete esql for the relevant response handling module is below.
Note the two IF's early on, the result of this is FALSE so the first exception is not thrown.
I ran through with debug in either case the environment......var fields were not populated.
Uhmmm.
CREATE COMPUTE MODULE WS_INVOCATION_CCTR_BuildReplyMessage1
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
-- CALL CopyEntireMessage();
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
--Define the Variables
DECLARE mySoapNS NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
DECLARE myXSI NAMESPACE 'http://www.w3.org/2001/XMLSchema-instance';
DECLARE myXSD NAMESPACE 'http://www.w3.org/2001/XMLSchema';
DECLARE myEnc NAMESPACE 'http://schemas.xmlsoap.org/soap/encoding/';
--myNS2 is namespace defining input and output methods
DECLARE myNS2 NAMESPACE 'http://ws-uat.xxxplatform.acompany.com/StoreCollection';
DECLARE somevar1 CHAR ;
DECLARE somevar2 CHAR ;
--Im assuming your message is in the XMLNS Domain.
--Ensure advanced property of HTTPRequest Node is Checked for response to replace input.
--Root.HTTPResponseHeader will contain the status code which should be 200.
--The body of the message (last root tree) will be SOAP response
IF InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorTypeCode
AND
InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorMessage
IS NULL
THEN
THROW USER EXCEPTION VALUES
('acompany WebService has returned an error. See Environment.myVariables.thisWebService.Reply fields in exception log at /mqlogs/trace/WS/WS_INVOCATION_CCTR_exceptions1 and 2 for more details.' ) ;
END IF ;
SET Environment.myVariables.thisWebService.SOAP = InputRoot.XMLNS ; -- output SOAP save for posterity
-- SET Environment.myVariables.thisWebService.Reply.var1 =
-- InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorTypeCode ;
-- SET Environment.myVariables.thisWebService.Reply.var2 =
-- InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorMessage ;
SET Environment.myVariables.thisWebService.Reply.var1 =
FIELDVALUE(InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorTypeCode) ;
SET Environment.myVariables.thisWebService.Reply.var2 =
FIELDVALUE(InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorMessage) ;
SET somevar1 = Environment.myVariables.thisWebService.Reply.var1 ;
SET somevar2 = Environment.myVariables.thisWebService.Reply.var2 ;
--the following code contains a bug - an exception is not thrown when it ought to be
IF InputRoot.HTTPResponseHeader."X-Original-HTTP-Status-Code" = '200'
THEN
IF somevar1 = '06' OR somevar1 = '07'
THEN
IF somevar2 = 'Cost center Update successful' OR somevar2 = 'Cost center creation successful'
THEN
SET Environment.myVariables.thisWebService.Reply.result = 'Positive response from acompany Web Service - I''m so pleased !' ;
ELSE
THROW USER EXCEPTION VALUES
('acompany WebService has returned an error. See Environment.myVariables.thisWebService.Reply fields in exception log at /mqlogs/trace/WS/WS_INVOCATION_CCTR_exceptions1 and 2 for more details.' ) ;
END IF ;
END IF ;
END IF ;
SET OutputRoot.XMLNS = InputRoot.XMLNS; --successfull response from WS store SOAP for later
SET Environment.myVariables.thisWebService.SOAP = InputRoot.XMLNS ; -- output SOAP save for posterity
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE; |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Jun 18, 2008 7:03 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Quote: |
SET Environment.myVariables.thisWebService.SOAP = InputRoot.XMLNS ; -- output SOAP save for posterity |
I noticed you're not setting the domain. This may have consequences later.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
vsr |
Posted: Thu Jun 19, 2008 1:24 pm Post subject: Re: SOAP navigation XMLNS |
|
|
Centurion
Joined: 04 Apr 2006 Posts: 104
|
hornbeam123 wrote: |
IF InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorTypeCode
AND
InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorMessage
IS NULL
THEN
THROW USER EXCEPTION VALUES
('acompany WebService has returned an error. See Environment.myVariables.thisWebService.Reply fields in exception log at /mqlogs/trace/WS/WS_INVOCATION_CCTR_exceptions1 and 2 for more details.' ) ;
END IF ;
|
Try
IF InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorTypeCode IS NULL
AND
InputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS2:updateCostCentreResponse.costCentreUpdateResponse.ValidationError.ErrorMessage
IS NULL
THEN
THROW USER EXCEPTION VALUES
('acompany WebService has returned an error. See Environment.myVariables.thisWebService.Reply fields in exception log at /mqlogs/trace/WS/WS_INVOCATION_CCTR_exceptions1 and 2 for more details.' ) ;
END IF ;
I read somewhere in this forum that there is a bug handling NULLs with XMLNS which is fixed in the latest fixpack. I am not sure but that could be a problem ! |
|
Back to top |
|
 |
hornbeam123 |
Posted: Fri Jun 20, 2008 5:29 am Post subject: SOAP navigation XMLNS |
|
|
Centurion
Joined: 01 Nov 2003 Posts: 101
|
I have cracked it.
My esql was correct but the WS provider had stitched me up.
The namespace they were using on response was not the same as on request and it should be. To prove my code I have changed my namespace declaration and the code as shown works.
I have also taken on board the IS NULL recommendation from VSR.
Thanks for everybody's assistance.
 |
|
Back to top |
|
 |
kimbert |
Posted: Fri Jun 20, 2008 6:15 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Also, fjb_saper said:
Quote: |
I noticed you're not setting the domain. This may have consequences later. |
In case you didn't get his meaning, you really must ensure that Environment.myVariables.thisWebService.SOAP is created in the XMLNS domain. Otherwise all of the field types ( XML.Attribute etc ) will be lost during the copy. |
|
Back to top |
|
 |
|