Viewed   254 times

I am very confused with

Soap curl request I found here an example SOAP request in PHP with CURL

and Soap request using SoapClient PHP http://php.net/manual/en/class.soapclient.php

My question and doubts are First - does these both fill the same purpose.

Second - Is there any performance difference if they are used for same purpose.

Thanks in advance

 Answers

1

You are right that they fill the same purpose. Though, the SoapClient has a lot of functionality for supporting SOAP requests built in and is using Curl somewhere as well.

As you can see in the discussion on SOAP with Curl the programmer constructs the SOAP envelope, the SoapClient can do that for you. The same holds for doing the method calls.

In the end, it is much easier to use the SoapClient.

Wednesday, November 2, 2022
 
dj2
 
dj2
3

SOAP is certainly not the ONLY way to implement Web services. If you're open to other paradigms, have a look at REST.

Unlike SOAP (which has multiple standards/vendors), REST is both vendor- and protocol-agnostic. Instead, RESTful Web services are implemented using these guidelines (from the Wikipedia article):

A RESTful web service (also called a RESTful web API) is a simple web service implemented using HTTP and the principles of REST. Such a web service can be thought about as a collection of resources. The definition of such a web service can be thought of as comprising three aspects:

* The base URI for the web service, such as http://example.com/resources/
* The MIME type of the data supported by the web service. This is often JSON, XML or YAML but can be any other valid MIME type.
* The set of operations supported by the web service using HTTP methods (e.g., POST, GET, PUT or DELETE).

Back to PHP, here is the reference guide for the ZendFramework implementation of REST Server functionality.

Also, here is a link to another answer I gave that references some useful information regarding ZendFramework and REST.

Monday, November 14, 2022
 
tomcy
 
5

Please check below code. It's working great.

class RevodocLeadSoapClient extends SoapClient {

    function __construct($wsdl, $options) {
        parent::__construct($wsdl, $options);
        $this->server = new SoapServer($wsdl, $options);
    }
    public function __doRequest($request, $location, $action, $version) { 
        $result = parent::__doRequest($request, $location, $action, $version); 
        return $result; 
    } 
    function __anotherRequest($call, $params) {
        $location = 'https://www.t1.revodoc.com/ws/services/RevoLeadWebService';
        $action = 'http://localhost/'.$call;
        $request = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
                    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:typens="https://secure.maventa.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
                    <SOAP-ENV:Body>
                    <RevodocLead xmlns="http://localhost/">';
        $request .= $params;
        $request .= '</RevodocLead>
                    </SOAP-ENV:Body>
                    </SOAP-ENV:Envelope>';
        $result =$this->__doRequest($request, $location, $action, '1');
        return $result;
    } 
}

// Create new SOAP client
$wsdl = 'https://www.t1.revodoc.com/ws/services/RevoLeadWebService?wsdl';
$client = new RevodocLeadSoapClient($wsdl, array(
    'cache_wsdl'    => WSDL_CACHE_NONE, 
    'cache_ttl'     => 86400, 
    'trace'         => true,
    'exceptions'    => true,
));

$operations = "RevodocLead";

$soap_request .= "<inode>";
$soap_request .= "<version>1.0</version>";
$soap_request .= "<sourceuserid>[email protected]</sourceuserid>";
$soap_request .= "<sourceid>18641254455</sourceid>";
$soap_request .= "<dealercode>1458445284</dealercode>";
$soap_request .= "<created>18-12-2015 13:45EST</created>";
$soap_request .= "<browser>Android Browser</browser>";
$soap_request .= "<os>Macintosh</os>";
$soap_request .= "<agent>[email protected]</agent>";
$soap_request .= "<product>mortgage-renewal</product>";
$soap_request .= "<name>success</name>";
$soap_request .= "<address>success</address>";
$soap_request .= "<email>success</email>";
$soap_request .= "<phone>success</phone>";
$soap_request .= "<propertyvalue>325000</propertyvalue>";
$soap_request .= "<mortgage>300000</mortgage>";
$soap_request .= "<referralcode>F3S2A2</referralcode>";
$soap_request .= "<note>value</note>";
$soap_request .= "<futurecontact>yes</futurecontact>";
$soap_request .= "</inode>";

// Make the request
try {
    $request = $client->__anotherRequest($operations, $soap_request);
} catch (SoapFault $e ){
    echo "Last request:<pre>" . htmlentities($client->__getLastRequest()) . "</pre>";
    exit();
}
//Print Response. #RevodocLeadResponse
echo '<pre><b>', htmlentities($request), '</b></pre>';
Wednesday, October 26, 2022
 
confiq
 
2

PHP strings can be specified not just in two ways, but in four ways.

  1. Single quoted strings will display things almost completely "as is." Variables and most escape sequences will not be interpreted. The exception is that to display a literal single quote, you can escape it with a back slash ', and to display a back slash, you can escape it with another backslash \ (So yes, even single quoted strings are parsed).
  2. Double quote strings will display a host of escaped characters (including some regexes), and variables in the strings will be evaluated. An important point here is that you can use curly braces to isolate the name of the variable you want evaluated. For example let's say you have the variable $type and you want to echo "The $types are". That will look for the variable $types. To get around this use echo "The {$type}s are" You can put the left brace before or after the dollar sign. Take a look at string parsing to see how to use array variables and such.
  3. Heredoc string syntax works like double quoted strings. It starts with <<<. After this operator, an identifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation. You don't need to escape quotes in this syntax.
  4. Nowdoc (since PHP 5.3.0) string syntax works essentially like single quoted strings. The difference is that not even single quotes or backslashes have to be escaped. A nowdoc is identified with the same <<< sequence used for heredocs, but the identifier which follows is enclosed in single quotes, e.g. <<<'EOT'. No parsing is done in nowdoc.

Notes: Single quotes inside of single quotes and double quotes inside of double quotes must be escaped:

$string = 'He said "What's up?"';
$string = "He said "What's up?"";

Speed:
I would not put too much weight on single quotes being faster than double quotes. They probably are faster in certain situations. Here's an article explaining one manner in which single and double quotes are essentially equally fast since PHP 4.3 (Useless Optimizations toward the bottom, section C). Also, this benchmarks page has a single vs double quote comparison. Most of the comparisons are the same. There is one comparison where double quotes are slower than single quotes.

Sunday, December 25, 2022
 
dariaa
 
1

Differences?

SOAP is more powerful, and is much preferred by software tool vendors (MSFT .NET, Java Enterprise edition, that sort of things).

SOAP was for a long time (2001-2007ish) seen as the protocol of choice for SOA. xml-rpc not so much. REST is the new SOA darling, although it's not a protocol.

SOAP is more verbose, but more capable.

SOAP is not supported in some of the older stuff. For example, no SOAP libs for classic ASP (that I could find).

SOAP is not well supported in python. XML-RPC has great support in python, in the standard library.

SOAP supports document-level transfer, whereas xml-rpc is more about values transfer, although it can transfer structures such as structs, lists, etc.

xm-rpc is really about program to program language agnostic transfer. It primarily goes over http/https. SOAP messages can go over email as well.

xml-rpc is more unixy. It lets you do things simply, and when you know what you're doing, it's very fast to deploy quality web services, even when using terminal text editors. Doing SOAP that way is a zoo; you really need a good IDE to make it feasible.

Knowing SOAP, though, will look much better on your resume/CV if you're vying for a Fortune 500 IT job.

xml-rpc has some issues with non-ascii character sets.

XML-RPC does not support named parameters. They must be in correct order. Not sure about SOAP, but think so.

Thursday, December 1, 2022
 
anthill
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :