繁体   English   中英

肥皂XML和PHP

[英]Soap XML and PHP

全新的肥皂。 我有这个WSDL链接。 http://mylink.com/somehint.asmx?WSDL

方法名称为“价格”。

我必须设置一个这样的请求。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Price>
         <!--Optional:-->
         <tem:request>
            <!--Optional:-->
            <tem:Username>MyUsername</tem:Username>
            <!--Optional:-->
            <tem:Password>Mypassword</tem:Password>
            <tem:Customer>002399</tem:Customer>
            <!--Optional:-->
            <tem:FromRes>23245</tem:FromRes>
            <!--Optional:-->
            <tem:ToRes>12334</tem:ToRes>
            <tem:Weight>39</tem:Weight>

         </tem:request>
      </tem:Price>
   </soapenv:Body>
</soapenv:Envelope>

但是我怎么用ph​​p写这个呢?

到目前为止,我已经写了这个,但是那行不通。 如果一切都不对,我并不感到惊讶。

$client = new SoapClient('http://mylink.com/somehint.asmx?WSDL', array('trace' => 1));
$res = $client->SoapFunction(array('Username'=>'Myusername','password'=>'Mypassword','Customer'=>'002399'));

我在我的代码中使用了类似的内容,也许可以帮助您解决问题! 我尝试根据您的数据进行调整,但也许您需要对其进行一些调整^^

$params = array('request'=>
                        array(
                              'Username' => 'Myusername',
                              'Password' => 'Mypassword',
                              'Customer' => 'Mycustomer',
                              'FromRes'  => 'Mypfromres',
                              'ToRes'    => 'Myptores',
                              'Weight'   => 'Mypweight'
                        ));

$wsdl = 'http://mylink.com/somehint.asmx?wsdl';

$options = array(
                 'uri'                => 'http://schemas.xmlsoap.org/soap/envelope/',
                 'style'              => SOAP_RPC,
                 'use'                => SOAP_ENCODED,
                 'soap_version'       => SOAP_1_1,
                 'cache_wsdl'         => WSDL_CACHE_NONE,
                 'connection_timeout' => 15,
                 'trace'              => true,
                 'encoding'           => 'UTF-8',
                 'exceptions'         => true,
                 );

try {
    $soap = new SoapClient($wsdl, $options);
    $data = $soap->Price($params);
}

catch(Exception $e) {
    die($e->getMessage());
}

print_r($data);

问候。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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