You are here:  » Having Trouble with parsing SOAP envelope, help much needed


Having Trouble with parsing SOAP envelope, help much needed

Submitted by r018u on Sat, 2008-05-31 13:47 in

Hello,

I am trying to parse info from a SOAP envelope to get data from gratisnetwork.com. The webservice is supplied by DirectTrack and the details can be found here:

http://secure.directtrack.com/api/soap_affiliate.php.

I am using the last service (getSubIDStats).

Here is code I am using with MagicParser to retreive the data:

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    
print_r($record);
  }
$xml =
'<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soapinterop.org/">
 <soapenv:Header/>   <soapenv:Body> <soap:getSubIDStats soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<client xsi:type="xsd:string">gratisinternet</client>
<add_code xsi:type="xsd:string">CD2643</add_code>
<password xsi:type="xsd:string">  {removed}  </password>
<primary xsi:type="xsd:string">subid1</primary>
<secondary xsi:type="xsd:string">subid2</secondary>
<tertiary xsi:type="xsd:string">subid3</tertiary>
<quaternary xsi:type="xsd:string">subid4</quaternary>
<keyword xsi:type="xsd:string"></keyword>
<program_id xsi:type="xsd:int">1432</program_id>
<start_date xsi:type="xsd:date">2008-04-01</start_date>
<end_date xsi:type="xsd:date">2008-04-31</end_date>
</soap:getSubIDStats>   </soapenv:Body></soapenv:Envelope>'
;
 
$formatString "xml|SOAP:Envelope/SOAP:BODY/m:getSubIDStatsRequest/";
 
MagicParser_parse("string://".$xml,"myRecordHandler",$formatString);
?>

I have been in contact with DirectTrack and they said:
"Hello, I am not very familiar with MagicParser, however when using the soap call from your attachment in soupUI I am able to have all of the information returned successfully. It appears as though something with the code is causing the call itself and not the information to be returned."

I don't know if this will help.. I am willing to give the password for testing if appropriate.
Any help would be greatly appreciated, thanks!

Submitted by support on Sat, 2008-05-31 14:01

Hi,

I think it's just the format string - i've pasted your sample XML into the demo tool,
and as normal when parsing SOAP responses with Magic Parser you can access all the
fields using the following Format String:

xml|SOAPENV:ENVELOPE/

http://www.magicparser.com/demo?fileID=4841596BEE329&record=1

In the case of this specific response, you can shorten the field names by parsing at
the GETSUBIDSTATS level, using this Format String:

xml|SOAPENV:ENVELOPE/SOAPENV:BODY/SOAP:GETSUBIDSTATS/

Hope this helps!
Cheers,
David.

Submitted by r018u on Sat, 2008-05-31 14:46

Hi, thanks for the reply.

I replaced the formatString with your suggestion. Now I can see the values inside the tags, but no data from Gratis is being sent or displayed.

Am I missing something? Thanks.

I'm testing it here, with the primary value (subid1):

http://www.freebietwist.com/auto_credit_sites/gratisAutoCreditor.php

Submitted by support on Sat, 2008-05-31 15:07

Hi,

I'm presuming that the script you are running is using:

  print $record["SOAPENV:BODY/SOAP:GETSUBIDSTATS/PRIMARY"];

...or if you used the second Format String:

  print $record["PRIMARY"];

...which based on the sample XML you posted is the correct value. As this is from the
data part of the XML, it will be whatever was returned from the server you made the
request to; so that part should be working fine...

If that's the case, then you need to look at your request to the web service and make
sure that you are making the request correctly based on the information you want to
receive...

Cheers,
David.

Submitted by r018u on Tue, 2008-06-03 01:25

Correct.

I have contacted DirectTrack and am awaiting a reply, as there is most probably something wrong with the request.

Submitted by smartbiz8 on Mon, 2010-02-01 04:57

I am having the same issue as r018u is having. The data I am seeing after running the script from above is "subid1". How would I go about retrieving data from a network to view the primary (subid1) data?

Hope to hear from you soon!

Thanks,

Dan

Submitted by support on Mon, 2010-02-01 09:51

Hi Dan,

I just followed up by email...

All the best,
David.