duanqiangwu9332 2017-06-23 10:02
浏览 1026

如何在soap请求中传递一个参数和xml数据

I have soap request in xml format. I want to convert into php SOAP. Request

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
    <AddContact xmlns="http://thankqportal.com/eModulesAPI" 
     xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
       <token>efgh5678</token>
       <contactXml>
         <Contact xmlns="http://thankqportal.com/eModulesAPI/Contact.xsd" 
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
              <title>Mr</title>
              <firstname>Luke</firstname>
              <keyname>Hawkins</keyname>
        </Contact>
      </contactXml>
  </AddContact>
  </s:Body>
 </s:Envelope>

Please help me here. I am stuck with contact xml. It is inner xml of xml. So How can I pass the xml to soap api.

I have written the code as per below:

  $xml = "<Contact>
        <firstname>$fname</firstname>
        <keyname>$keyname</keyname>
        </Contact>"; 
$args = array("token" =>$token, "contactXml"  => new SoapVar($xml, XSD_ANYXML));

try {
        $result =   $soapClient->AddContact($args);

    } catch (SoapFault $e) {
       echo '<pre>';    
       echo "Error!:    ";
       echo $e -> getMessage ();
   }

But it gives the error: Error!: Object reference not set to an instance of an object.

So please help me here where I am wrong in my code.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料