Soap Question

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
LVL 1
movieprodwAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
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
Slick812Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
movieprodwAuthor Commented:
Great info!

Thank you both, this helps a lot.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.