繁体   English   中英

SOAP:PHP调用.net Web服务

[英]SOAP: PHP invoking .net webservice

嗨,大家可以对如何在php中创建此请求有个想法。 正在调用.net soap网络服务。

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <confirmCustomerReq xmlns="http://www.nrs.eskom.co.za/xmlvend/revenue/2.1/schema">
      <clientID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
      <terminalID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
      <msgID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" dateTime="xx" uniqueNumber="xx" />
      <authCred xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema">
        <opName>xxx</opName>
        <password>xxx@#1</password>
      </authCred>
      <idMethod xmlns:q1="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="q1:VendIDMethod">
        <q1:meterIdentifier xsi:type="q1:MeterNumber" msno="xx" />
      </idMethod>
    </confirmCustomerReq>
  </soap:Body>
</soap:Envelope>

我尝试使用SoapClient类和curl,但仍然无法获得下面的确切xml,这是我的代码片段。 下面正在使用SoapClient类

array( 'ConfirmCustomerReq'=>array( 
                'ClientID' =>array('xsi:type'=>"EANDeviceID", 'ean'=>"xxxx"),
                'terminalID'=>array('xsi:type'=>"EANDeviceID", 'ean'=>"xxx"),
                'authCred' => array(
                           'opName' => "$this->username",
                            'password' => "$this->pass"
                           ),               
                'msgID' => array('dateTime'=>"xxx" ,'uniqueNumber'=>"xxx" ),
                'idMethod' => array('xsi:type'=>"q1:VendIDMethod",
                  'meterIdentifier' =>array( 'xsi:type'=>"q1:MeterNumber" ,'msno'=>"xxx")
    )
    )
    );

和卷曲

function main(){
$xml ='<?xml version="1.0" encoding="utf-8"?><soap:Envelope     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
        <confirmCustomerReq xmlns="http://www.nrs.eskom.co.za/xmlvend/revenue/2.1/schema">
          <clientID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
          <terminalID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="EANDeviceID" ean="xx" />
          <msgID xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" dateTime="xx" uniqueNumber="xx" />
          <authCred xmlns="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema">
            <opName>xxx</opName>
            <password>xxx@#1</password>
          </authCred>
          <idMethod xmlns:q1="http://www.nrs.eskom.co.za/xmlvend/base/2.1/schema" xsi:type="q1:VendIDMethod">
            <q1:meterIdentifier xsi:type="q1:MeterNumber" msno="xx" />
          </idMethod>
        </confirmCustomerReq>
      </soap:Body>
    </soap:Envelope>';

try{
$soap_do = curl_init();
  curl_setopt($soap_do, CURLOPT_URL, "https://www.utilitiesworld.co.za/SecureThirdPartyInterface/VendingService.asmx" );
  curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
  curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
  //curl_setopt($soap_do, CURLOPT_CAINFO, 'XXXXXXXXXXXXXX');
  curl_setopt($soap_do, CURLOPT_POST,           true );
  curl_setopt($soap_do, CURLOPT_FRESH_CONNECT, TRUE);
  curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $xml);
  //curl_setopt($soap_do, CURLOPT_HEADER, false);


   $xml_result = curl_exec($soap_do);
   echo curl_error($soap_do);
      //$result=parse_str($xml_result);
    //var_dump($xml_result);
    curl_close($soap_do);
}

肥皂客户端模态存在于PHP

http://php.net/manual/zh/soapclient.soapclient.php

暂无
暂无

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

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