?
Solved

Soap Question

Posted on 2014-08-22
3
Medium Priority
?
294 Views
Last Modified: 2016-02-26
Hello,

I was given this:

POST /cart_advanced.asmx HTTP/1.1
Host: api.3dcart.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <runQuery xmlns="http://3dcart.com/">
      <storeUrl>string</storeUrl>
      <userKey>string</userKey>
      <sqlStatement>string</sqlStatement>
      <callBackURL>string</callBackURL>
    </runQuery>
  </soap12:Body>
</soap12:Envelope>

Open in new window


And I am not sure what to do with it, I have used something similar in the past but I would call it with a url string...

The tutorial does not tell how to use it, simply shows the call and the response, the call is what I posted above.

Any tips would be appreciated.

Matt
0
Comment
Question by:movieprodw
3 Comments
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 total points
ID: 40280412
Might help if we had some more context.  Can you please post the tutorial or a link to it?

Interpreting the code into PHP it might look something like this.  You would want to substitute usable data for the word "string" inside these XML tags.  It fails with curl ERRNO=22, which means something like the resource returned 403 forbidden (probably because some kind of authentication user name is missing).
http://iconoun.com/demo/temp_movieprodw.php

<?php // demo/temp_movieprodw.php
error_reporting(E_ALL);


/** SEE http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28503969.html
 *
 * POST /cart_advanced.asmx HTTP/1.1
 * Host: api.3dcart.com
 * Content-Type: application/soap+xml; charset=utf-8
 * Content-Length: length
 *
 * <?xml version="1.0" encoding="utf-8"?>
 * <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
 *   <soap12:Body>
 *     <runQuery xmlns="http://3dcart.com/">
 *       <storeUrl>string</storeUrl>
 *       <userKey>string</userKey>
 *       <sqlStatement>string</sqlStatement>
 *       <callBackURL>string</callBackURL>
 *     </runQuery>
 *   </soap12:Body>
 * </soap12:Envelope>
 *
 * */


// SET UP THE POST STRING
$xml = <<<EOD
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <runQuery xmlns="http://3dcart.com/">
      <storeUrl>string</storeUrl>
      <userKey>string</userKey>
      <sqlStatement>string</sqlStatement>
      <callBackURL>string</callBackURL>
    </runQuery>
  </soap12:Body>
</soap12:Envelope>
EOD;

// SET UP THE PROTOCOL, URL, PATH
$url = 'http://' . 'api.3dcart.com' . '/cart_advanced.asmx';

// CALL CURL TO POST THE DATA
$htm = curl_post($url, $xml, 3, TRUE);

// SHOW WHAT CAME BACK, IF ANYTHING
if ($htm)
{
    echo "<pre>";
    echo htmlentities($htm);
}
else
{
    echo "NO RESPONSE YET FROM $url -- MAYBE BECAUSE IT IS RUNNING ASYNCHRONOUSLY";
}


// A CURL FUNCTION TO MAKE A POST-METHOD REQUEST
function curl_post($url, $post_string=NULL, $timeout=2, $error_report=TRUE)
{
    // PREPARE THE CURL CALL
    $curl = curl_init();
    curl_setopt( $curl, CURLOPT_URL,            $url           );
    curl_setopt( $curl, CURLOPT_HEADER,         FALSE          );
    curl_setopt( $curl, CURLOPT_POST,           TRUE           );
    curl_setopt( $curl, CURLOPT_POSTFIELDS,     $post_string   );
    curl_setopt( $curl, CURLOPT_ENCODING,       'gzip,deflate' );
    curl_setopt( $curl, CURLOPT_TIMEOUT,        $timeout       );
    curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE           );
    curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, TRUE           );
    curl_setopt( $curl, CURLOPT_FAILONERROR,    TRUE           );

    // EXECUTE THE CURL CALL
    $htm = curl_exec($curl);
    $err = curl_errno($curl);
    $inf = curl_getinfo($curl);

    // ON FAILURE
    if (!$htm)
    {
        // PROCESS ERRORS HERE
        if ($error_report)
        {
            echo "CURL FAIL: $url TIMEOUT=$timeout, CURL_ERRNO=$err";
            echo "<pre>\n";
            var_dump($inf);
            echo "</pre>\n";
        }
        curl_close($curl);
        return FALSE;
    }

    // ON SUCCESS
    curl_close($curl);
    return $htm;
}

Open in new window

0
 
LVL 34

Accepted Solution

by:
Slick812 earned 1000 total points
ID: 40280665
greetings movieprodw, , using a server communication with a SOAP client is not an easy thing to understand, the TWO WAY SOAP server connection is different to setup and use than any REST or HTTP protocol web service.  I have not used the "3D cart" service, but all of these Ecommerce data services offer a healthy amount of support, because you are paying them for that. You might contact the "3D cart" people and ask them questions.  As to this question , Please go to the following page in the 3D cart forum -
     http://forums.3dcart.com/general-configuration-questions/1471-3dcart-api-xml.html

and scroll down, and you will find a full PHP code to use the 3D cart SOAP. As I said Using the SOAP is not so easy, the PHP code on that page shows the -
    $result = $client->getProductCount($param);

and this IS NOT the code for your "runQuery" method, but may show you how to set up the SOAP connection.
0
 
LVL 1

Author Closing Comment

by:movieprodw
ID: 40280711
Great info!

Thank you both, this helps a lot.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question