SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with SOAP Request and Response

    I'm new to this SOAP thing, 'been doing some googling
    but haven't found what I'm looking for.

    There is a soap request in this format:

    Code:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://url.com/" xmlns:web="http://schemas.url2.org">
      <soapenv:Header/> 
      <soapenv:Body> 
      <ser:GetTransactionData> 
      <ser:transactionQueryRequest> 
      <web:Hash>xyz123</web:Hash>
       <web:ProductId>1122</web:ProductId>
        <web:TransactionReference>889900</web:TransactionReference> 
        </ser:transactionQueryRequest> 
        </ser:GetTransactionData> 
        </soapenv:Body> 
        </soapenv:Envelope>
    The respose will be in this format:

    Code:
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
     <s:Body> 
    <GetTransactionAcquirerDataResponse xmlns="http://url.com/"> 
    <GetTransactionAcquirerDataResult xmlns:a="http://schemas.url2.org" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <a:ResponseCode>01</a:ResponseCode> 
    <a:ResponseDescription>OK</a:ResponseDescription> 
    <a:Amount>1000000</a:Amount> 
    <a:CardNumber>0</a:CardNumber> 
    <a:MerchantReference>889900</a:MerchantReference> 
    <a:PaymentReference>MER|REF|007</a:PaymentReference>
     <a:RetrievalReferenceNumber>34343883498349834</a:RetrievalReferenceNumber> 
    </GetTransactionAcquirerDataResult> 
    </GetTransactionAcquirerDataResponse> 
    </s:Body> 
    </s:Envelope>
    How do I make the SOAP request within a PHP script and how do I
    process the response and extract the needed values out; ResponseCode, Amount, CardNumber etc.

    Many Thanks.

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2012
    Location
    Scarborough, North Yorkshire, United Kingdom
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use cURL http://uk3.php.net/curl to transfer the data, something like:


    PHP Code:
    $data=    '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://url.com/" xmlns:web="http://schemas.url2.org">
    <soapenv:Header/> 
    <soapenv:Body> 
    <ser:GetTransactionData> 
    <ser:transactionQueryRequest> 
    <web:Hash>xyz123</web:Hash>
    <web:ProductId>1122</web:ProductId>
    <web:TransactionReference>889900</web:TransactionReference> 
    </ser:transactionQueryRequest> 
    </ser:GetTransactionData> 
    </soapenv:Body> 
    </soapenv:Envelope>'
    ;
                    
    $url 'WhereverYouAreSendingIt.com';

    $ch curl_init();
    curl_setopt($chCURLOPT_URL$url);
    curl_setopt($chCURLOPT_POST1);
    curl_setopt($chCURLOPT_POSTFIELDS$data);
            
    curl_setopt($chCURLOPT_HTTPHEADER, array("Content-Type: text/xml","SOAPAction: \"/soap/action/query\"""Content-length: ".strlen($data))); 
        
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
    $response curl_exec($ch);
    echo 
    "<pre>";
    print_r($reponse);
    echo 
    "</pre>" 
    Richard
    Resell SSL Certificates - API / WHMCS / HostBill / ClientExec
    ServerTastic - RapidSSL, Geotrust, Thawte, Symantec, SmarterTools and more

  3. #3
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but I don't understand this bit :

    $url = 'WhereverYouAreSendingIt.com';

    What url.

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,214
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tentim View Post
    Thanks, but I don't understand this bit :

    $url = 'WhereverYouAreSendingIt.com';

    What url.
    There should be a service or URL that you are to send your SOAP message to, that is what the URL should be.

  5. #5
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm getting an Internal Server Error as the response, please can you help double check this bit
    whether it is really ok:

    "SOAPAction: \"/soap/action/query\"",

  6. #6
    SitePoint Zealot
    Join Date
    Jul 2012
    Location
    Scarborough, North Yorkshire, United Kingdom
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should have an error.log file somewhere with a detailed message.
    Richard
    Resell SSL Certificates - API / WHMCS / HostBill / ClientExec
    ServerTastic - RapidSSL, Geotrust, Thawte, Symantec, SmarterTools and more


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
  •