简体   繁体   中英

How to get response from wsdl with complex Type using php

Help me please. I have wsdl with complex type example like this :

<WL5G3N0:definitions name="commandModificationiSiska">
  <xsd:complexType name="Input">
    <xsd:sequence>
      <xsd:element minOccurs="0" name="dn" nillable="true" type="xsd:string"/>
      <xsd:element name="ptOffer" nillable="true" type="tns:ptOffer"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="ptOffer">
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" name="array" nillable="true" type="tns:array"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="array">
    <xsd:sequence>
      <xsd:element name="itemTyp" nillable="true" type="xsd:string"/>
      <xsd:element name="itemCode" nillable="true" type="xsd:string"/>
      <xsd:element name="itemRefPack" nillable="true" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>

actually i have found on try to follow one solution in this link . In that link is similar with my problem but still not working.

and this is my php script i write in

error_reporting(E_ALL);

ini_set('display_errors', 1);

$param = new StdClass();

$param->array = new StdClass();

$param->input = new StdClass();

$param->input->dn = "XX2042XXXX";

$param->array->itemTyp = "2";

$param->array->itemcode = "AUTOCON2";

$param->array->itemRefPack = "";

$wsdl_file =  "test.wsdl";

  $client = new SoapClient($wsdl_file,array("trace"=> 1,"exceptions" => 0,"cache_wsdl" => 0));

  print_r($client->commandModificationiSiska($param));

  echo "<br/>================<br/>";

  echo "<p>Request :".htmlspecialchars($client->__getLastRequest()) ."</p>";

  echo "<p>Response:".htmlspecialchars($client->__getLastResponse())."</p>";

Maybe someplace had resolved for this problem and can help me in here ..

Problems solved. Very simple solution. Input has separated two parameter :

  1. dn

  2. ptoffer

    "ptoffer" separated in 3 input parameter was named with "array". "array" have 3 parameter , there are itemCode,itemtyp,itemrefpack. Thats the point.

i just have to do this for get respone from that wsdl file.

$client = new SoapClient($wsdl_file,array("trace"=> 1,"exceptions" => 0,"cache_wsdl" => 0));

print_r( $client->commandModificationiSiska(array(
                                                "dn" => "1222XXX",
                                                "ptOffer" => array('array' => array("itemTyp" => 2,
                                                                  "itemCode" => "blabla",
                                                                  "itemRefPack" => ""
                                                                  ))
                                                ))); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM