首页 > 解决方案 > 肥皂。PHP 中的 XML 示例请求

问题描述

如何在 PHP 中实现 XML 示例请求?我对参数和发送 WS url 感到困惑......

例子:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="WS"> //here is my ws server URL
   <soapenv:Header/>
   <soapenv:Body>
      <ws:calculatePrice>
         <arg0 username="username" password="password">
            <calculationInput var1="xxx" var2="xxx"/>
         </arg0>
      </ws:calculatePrice>
   </soapenv:Body>
</soapenv:Envelope>

我试过这个,但没有成功。

<?php 

try{
    $soapclient = new SoapClient('WSDL'); //here is WSDL server

    $result = $soapclient->calculatePremiumRegistered(array(
        'arg0' => array('username' => 'username', 'password' => 'password'), 
        array('calculationInput' => array('var1' => 'xxx', 'var2' => 'xxx'))
    ));

    print_r($result);

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

?>

我怎样才能正确地写出这些论点?如何发送 WS 服务器信息?

标签: phpxmlsoap

解决方案


推荐阅读