WebService SOAP WSDL UDDI uses PHP's curl, PHP5 soapclient for synchronization

Source: Internet
Author: User
Tags soap soapui wsdl

First, the basic noun

WebService is a remote invocation technique across programming languages and cross-operating system platforms. Different systems, different languages of the data exchange methods are different, which leads to different systems, different languages between the transmission of data is very troublesome, based on this, WebService appeared. SOAP, WSDL, and UDDI form the foundation of the WebService platform.
SOAP (Simple Object Access Protocol):
To pass the data, first we want to unify the format of the data, so that everyone according to the same specification to ensure that the data format unified, will not be confused. SOAP is a lightweight protocol that is based on XML definitions.
WSDL (Web Services Description Language):
The WSDL file is used to tell the user the specific format of the data, data parameters, service addresses, available functions, and so on, to parse the WSDL file to know the service content provided by the other. Recommended software SOAPUI parsing WSDL files.
UDDI(Universal Description, Discovery and integration):
Unified description, Discovery, and integration for centralizing and locating WSDL profiles, serving as a directory server and sharing services.
Although all are new concepts, but in fact WebService are based on some old technology, so when understanding the principle, you can use the original technology to achieve the same function.

Second, PHP implementation synchronization

Since this part only involves synchronization, all of it can be done using curl. Here's the code:
Just add the appropriate method to the header field of the HTTP and pass the data with XML. By the same token, other languages can be implemented as well. About methods and XML formats are recommended for use with SOAPUI parsing WSDL files.

Private function http_request_xml($url,$data = null,$arr_header = null){
        $curl = curl_init();
        Curl_setopt($curl, CURLOPT_URL, $url);
        // curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        // curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
        If (!empty($data)){
            Curl_setopt($curl, CURLOPT_POST, 1);
            Curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            Curl_setopt($curl, CURLOPT_HTTPHEADER, $arr_header);
        Curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        Return $output;

$xml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:app=\"http://siebel.com/Voucher/Apply\">
$arr_header[] = "Content-type: text/xml"; //pass using xml format
$arr_header[] = "SOAPAction:\"document/http://siebel.com/Voucher/Apply:VoucherApply\""; //Add swdl method
$res = $this->http_request_xml($url, $xml, $arr_header);

PHP5 the method
1, in the PHP configuration file php.ini, find


To remove the number of a reboot.

2. Get methods and Parameters:

try {
    $client = new SoapClient("http://***.******.com/services?wsdl");
} catch (SOAPFault $e) {
    print $e;

3, with parameter access:

try {
    $client = new SoapClient(‘http://***.*******.com/services?wsdl‘);
    $xml = "<?xml version=‘1.0‘ encoding=‘UTF-8‘ ?>";
    $return = $client->function($xml);
} catch (SOAPFault $e) {

Third, WSDL detailed

Open the WSDL file directly as follows:

<?xml version="1.0" encoding="utf-8"?>

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsdLocal1="http://www.siebel .com/xml/TESITOSynTxn" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns= "http://siebel.com/Transaction" targetNamespace="http://siebel.com/Transaction"> // The root element of all WSDL documents is the definitions element. This element encapsulates the entire document.
  <types> // The data type used by the web service. The types element is used as a container to define various data types not described in the XML schema built-in types.
    <xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://www.siebel.com/xml/TESITOSynTxn"> // xsd root element
        <xsd:documentation>Copyright (C) 2001-2004</xsd:documentation>
      <xsd:element name="ListOfLoyTransaction" type="xsdLocal1:ListOfLoyTransaction"/> //Define a data type

        <xsd:complexType name="ListOfLoyTransactionTopElmt">
            <xsd:element name="ListOfLoyTransaction" maxOccurs="1" minOccurs="1" type="xsdLocal1:ListOfLoyTransaction"/> //Define a subdata type

        <xsd:complexType name="ListOfLoyTransaction">
            <xsd:element name="Transaction" maxOccurs="unbounded" minOccurs="0" type="xsdLocal1:LOYTransaction"/>

        <xsd:complexType name="Transaction"> // parent element
          <xsd:sequence> // indicates that the child elements appear in order
            <xsd:element name="RedMark" maxOccurs="1" minOccurs="0" type="xsd:string"/> // maxOccurs maximum number minOccurs minimum quantity, optional parameter implementation
            <xsd:element name="ProdCode" maxOccurs="1" minOccurs="0" type="xsd:string"/>
            <xsd:element name="OrderType" maxOccurs="1" minOccurs="0" type="xsd:string"/>


    <xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://siebel.com/Transaction">
      <xsd:import namespace="http://www.siebel.com/xml/SynTxn"/> // The import element makes it possible to use defined elements in the namespace specified in other WSDL documents in the current WSDL document.

      <xsd:element name="Txn_Input">
            <xsd:element ref="xsdLocal1:ListOfLoyTransaction"/>

      <xsd:element name="Txn_Output">
            <xsd:element name="ErrorFlag" type="xsd:string"/>
            <xsd:element name="ErrorMessage" type="xsd:string"/>


  <message name="Txn_Input"> //Message used by web service
    <part name="Txn_Input" element="tns:Txn_Input"/>
  <message name="Txn_Output"> //Message used by web service
    <part name="Txn_Output" element="tns:Txn_Output"/>

  <portType name="spcSyn_spcTransaction_spcWorkflow"> // The portType element defines the abstract interface for the web service. The portType element is implemented by the binding and service elements.
    <operation name="Txn">
      <input message="tns:Txn_Input"/>
      <output message="tns:Txn_Output"/>

  <binding name="spcSyn_spcTransaction_spcWorkflow" type="tns:spcSyn_spcTransaction_spcWorkflow"> // The communication protocol used by the web service maps an abstract portType to a specific set of protocols (SOAO and HTTP), messaging styles, and encoding styles.
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="Txn">
      <soap:operation soapAction="document/http://siebel.com/Transaction:Txn"/>
        <soap:body use="literal"/>
        <soap:body use="literal"/>

  <service name="SynTransaction"> // The service element contains one or more port elements, each of which represents a different web service.
    <port binding="tns:spcSyn_spcTransaction_spcWorkflow" name="spcSyn_spcTransaction_spcWorkflow">
      <soap:address location=""/>


(PHP) Call WebService with curl for weather information
 * Call webService with cURL to get weather information
 * User: Ollydebug
 * Date: 2015/11/11
 * Time: 19:44
//On the WeatherWs server, the default city of the city of theCityCode = 864
$data = ‘theCityCode=864&theUserID=‘;
$curlobj = curl_init();
Curl_setopt($curlobj,CURLOPT_HTTPHEADER,array("application/x-www-form-urlencoded;charset=utf-8;","Content-length: ".strlen($data)));
Curl_setopt($curlobj, CURLOPT_USERAGENT, ‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36‘);
$rtn = curl_exec($curlobj);
    Echo $rtn;
    Echo ‘Curl error: ‘.curl_errno($curlobj);

WebService SOAP WSDL UDDI uses PHP's curl, PHP5 soapclient for synchronization

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.