2014-10-29 131 views
0

请帮助我。我有一个复杂的类型如WSDL这样的:如何从复杂类型的wsdl使用php获得响应

<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> 

其实我已经在尝试发现跟随this link一个解决方案。在那个链接是类似于我的问题,但仍然无法正常工作。

,这是我的PHP脚本我写

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>"; 

也许某个地方已经解决了这个问题,并可以帮助我在这里..解决

+0

感谢@Anju Vineesh编辑我的问题。你能回答吗? – firman 2014-10-29 04:47:59

回答

0

问题。 非常简单的解决方案。 输入已分离的两个参数:

  1. DN

  2. ptoffer

    “ptoffer” 与 “阵列” 3输入参数被命名为分离。 “数组”有3个参数,有itemCode,itemtyp,itemrefpack。这才是重点。

我只需要这样做就可以获得该wsdl文件的响应。 $; $ 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" => "" 
                   )) 
               )));