SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    parse soap response via curl

    Hi Guys,

    I am using curl to connect a 3rd party web service and I am getting the correct response.The problem is I can't parse the response into an array and then get the string.

    curl code

    PHP Code:
    $ch curl_init();                         
                
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);             
                
    curl_setopt($chCURLOPT_URL$url);
                
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
                
    curl_setopt($chCURLOPT_USERPWD$soapUser.":".$soapPassword); // username and password - declared at the top of the doc
                
    curl_setopt($chCURLOPT_HTTPAUTHCURLAUTH_ANY);
                
    curl_setopt($chCURLOPT_TIMEOUT10);
                
    curl_setopt($chCURLOPT_POSTtrue);
                
    curl_setopt($chCURLOPT_POSTFIELDS$xml_post_string); // the SOAP request
                
    curl_setopt($chCURLOPT_HTTPHEADER$headers);

                
    // converting
                
    $response curl_exec($ch); 
    the response is

    Code:
    <env:Envelope>
         <env:Header/>
                  <env:Body>
                          <ns2:getCriteriaResponse>
                                   <ns2:standardCriteriaWithLovs>
                                              <adLanguages>
                                                       <language>
                                                                 <label>English (UK)</label>
                                                                   <value>UK</value>
                                                      </language>
                                              </adLanguages>
                                   </ns2:standardCriteriaWithLovs>
                          </ns2:getCriteriaResponse>
                   </env:Body>
    </env:Envelope>
    How can get that language code that is English (UK) and the value UK in an array.

    Please help.Thanks in advance.

  2. #2
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @bbolte Many thanks for the link.I have seen that before.But the problem is that in my case the xml file is not generating and the response body which I can see (from firebug > net panel) is inside my question. Somehow it is not a proper xml I guess.When I do print_r($response) it just prints the html in the browser.

  5. #5
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, missed the SOAP stuff. Look into NuSOAP.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •