I am trying to find a way to automate a SOAP call and have the response which is in XML format being parsed and put into a data extension in the proper format (data to columns)

I can create the SOAP call in a Cloud Page fine which outputs the response like this

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
         <wsu:Timestamp wsu:Id="Timestamp-45ba12be-1b6d-4f55-a5c3-af7f0b21dddd">
      <RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <Results xsi:type="AccountUser">
            <PartnerKey xsi:nil="true"/>
            <ObjectID xsi:nil="true"/>

What I tried doing is create another cloud page with Ampscript and use the HTTPGet method parsing the response cloud page to parse the elements and the write to a data extension.

The code I am using to parse the SOAP response

%%[VAR @xml, @userid, @email, @activeflag, @rows, @cnt 

SET @xml = HTTPGet("https://pub.s1.exacttarget.com/page")
SET @userid = BuildRowsetFromXML(@xml,"//Results/UserID",1)
SET @email = BuildRowsetFromXML(@xml,"//objectid/email",1)
SET @activeflag = BuildRowsetFromXML(@xml,"//objectid/activeflag",1)

IF RowCount(@userid) > 5 THEN
SET @rows = 5
SET @rows = RowCount(@userid)

IF @rows >= 1 THEN
FOR @cnt = 1 to @rows DO
SET @userid = Field(Row(@userid,@cnt),"Value")


%%[NEXT @cnt

Is it because it is not formed as a typical xml but a SOAP envelope? Or is there a better way of doing this?

The code isn't perfect as I am just trying to test that it actually can parse the XML but nothing is coming back.


1 Answer 1


I think you can't use the : characters in element names in order for the BuildRowsetFromXML functions to work. You might also want to remove all namespaces first as well. You can do both of these via ampscript replace methods prior to building your rowset. You want the XML you're trying to parse to be super-simple.

You could also try to use TranformXML to turn the response into a text representation of the code you need to execute and put that string through a TreatAsContent call. Probably a bad idea when you think about it, but it would likely work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .