ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Accessing elements of SOAP Response Message

Post new topic  Reply to topic
 Accessing elements of SOAP Response Message « View previous topic :: View next topic » 
Author Message
sandeep.nandanwar
PostPosted: Wed Mar 04, 2015 8:12 pm    Post subject: Accessing elements of SOAP Response Message Reply with quote

Novice

Joined: 21 Jan 2015
Posts: 13

Hi,

Scenario : I am sending a request message to a web service and getting a response back from the web service.

FLOW : MQINPUT->COMPUTE->SOAPREQUEST->COMPUTE->MQOUTPUT

The response is as follows.

Code:
<SOAP_Domain_Msg
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <Context operation="getCustomerIDs"
        operationType="REQUEST_RESPONSE"
        portType="YIFWebService"
            portTypeNamespace="http://ejb.rpc.webservices.services.interop.yantra.com"
        port="YIFWebService" service="YIFWebServiceService"
        fileName="/var/mqsi/components/BRICR2/a68958c9-4b01-0000-0080-c045a0282ec6/config/XSD/OMS_SOAP_Request/com/yantra/interop/services/webservices/rpc/ejb/YIFWebService.wsdl">
  <SOAP_Version>1.1</SOAP_Version>
  <Namespace xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
 </Context>
 <Header soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
 <Body soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <p123:getCustomerIDsResponse xmlns:p561="http://ejb.rpc.webservices.services.interop.yantra.com">
   <getCustomerIDsReturn xsi:type="xsd:string">
<?xml version="1.0" encoding="UTF-8"?>.
<CustomerList>.
<Customer CustomerID="100000000" CustomerType="09".        ExternalCustomerID="200000" OrganizationCode="XXX">.
        <Extn Status="0"/>.
        <CustomerContactList>.           
             <CustomerContact CustomerContactID="12345678"/>.             
        </CustomerContactList>.
    </Customer>.
</CustomerList>.
</getCustomerIDsReturn>
  </p123:getCustomerIDsResponse>
 </Body>
</SOAP_Domain_Msg>


When I set the following statement as NULL,
SETOutputRoot.SOAP.Body.ns:getCustomerIDsResponse.getCustomerIDsReturn = NULL;
the content which I want to access from the getCustomerIDsReturn gets NULL. However I am not able to store it in ENVIRONMENT variable and extract some data from it.What should be done to retrieve the CustomerId from the response.

It would be really grateful if someone could share some knowledge in this stuff.

Thanks in Advance.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Mar 04, 2015 11:17 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

When I am testing a WebService like this I create a flow that looks like sometrhing like this

MQInput->Compute->SOAP Envelope->SOAP Request->SOAP Extract-Compute->MQOutput

Then there is the bit of the actual message that you are interested in.
Code:

<p123:getCustomerIDsResponse xmlns:p561="http://ejb.rpc.webservices.services.interop.yantra.com">
<getCustomerIDsReturn xsi:type="xsd:string">
<?xml version="1.0" encoding="UTF-8"?>
  <CustomerList>
   <Customer CustomerID="100000000" CustomerType="09". ExternalCustomerID="200000" OrganizationCode="XXX">. <Extn Status="0"/>
    <CustomerContactList>
      <CustomerContact CustomerContactID="12345678"/>
    </CustomerContactList>
  </Customer>
 </CustomerList>
</getCustomerIDsReturn>
</p123:getCustomerIDsResponse>


Does that help you get to the Data?

The value you need is an Attribute and is nexted several more layers down than you are using in your ESQL.

I'd also question why there is a

<?xml version="1.0" encoding="UTF-8"?>

In the middle of the XML. It looks like that the developers of the Webservice might be a bit sloppy in their code.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
sandeep.nandanwar
PostPosted: Thu Mar 05, 2015 3:39 am    Post subject: In the middle of the XML. It looks like that the developers Reply with quote

Novice

Joined: 21 Jan 2015
Posts: 13

Hi,

The approach which I am follwing now is I am storing all the text
Code:
<?xml version="1.0" encoding="UTF-8"?>
  <CustomerList>
   <Customer CustomerID="100000000" CustomerType="09". ExternalCustomerID="200000" OrganizationCode="XXX">. <Extn Status="0"/>
    <CustomerContactList>
      <CustomerContact CustomerContactID="12345678"/>
    </CustomerContactList>
  </Customer>
 </CustomerList>

which is inside getCustomerIDsResponse in an Environment variable by Using

SET Environment.TXT = InputRoot.SOAP.Body.ns:getCustomerIDsResponse.getCustomerIDsReturn;

Now I am thinking to reparse this xml and then retrieve the elements needed.

I will update if this approach works.

Thanks,
Sandeep
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Mar 05, 2015 4:08 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

you will hve problems if you don't assign a parser to the Environment tree because you have Attributes in your data structure.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
joebuckeye
PostPosted: Thu Mar 05, 2015 10:36 am    Post subject: Reply with quote

Partisan

Joined: 24 Aug 2007
Posts: 365
Location: Columbus, OH

smdavies99 wrote:
I'd also question why there is a

<?xml version="1.0" encoding="UTF-8"?>

In the middle of the XML. It looks like that the developers of the Webservice might be a bit sloppy in their code.


I bet that portion is actually inside CDATA. Or the devs are handling that data as a string and not parsed XML.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Mar 05, 2015 10:46 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

joebuckeye wrote:
smdavies99 wrote:
I'd also question why there is a

<?xml version="1.0" encoding="UTF-8"?>

In the middle of the XML. It looks like that the developers of the Webservice might be a bit sloppy in their code.


I bet that portion is actually inside CDATA.


It would actually have to be marked that way in the XML document itself.
Back to top
View user's profile Send private message
joebuckeye
PostPosted: Fri Mar 06, 2015 11:14 am    Post subject: Reply with quote

Partisan

Joined: 24 Aug 2007
Posts: 365
Location: Columbus, OH

It all depends on how the response XML was captured.

The Datapower probe for example "eats" CDATA tags so if you capture the XML there you wouldn't get them in your XML.

There are plenty of home brew XML parsers out there that fail to handle CDATA properly. It usually starts with people deciding they don't need a real XML parser to grab a couple fields or create a simple XML.

Heck, I had one project where a vendor product couldn't handle XML attributes so we had to add a transformation step to our process to remove them and add them back on the way in and out.

But I was just offering up one theory, I would bet the more likely is that whatever created that response treated the internal XML document as a string instead of parsed XML.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Mar 06, 2015 11:15 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

joebuckeye wrote:
It all depends on how the response XML was captured.

The Datapower probe for example "eats" CDATA tags so if you capture the XML there you wouldn't get them in your XML.


Sure, but this is apparently data being read from an MQ queue.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Accessing elements of SOAP Response Message
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.