これはWebサービス/ SOAPで初めてのことです。私はPHPを使用しても.Net Webサービスを消費しようとしていますが、無駄です。私は検索し、Googleがこれに関連する何かをスローするすべてのページを読んだが、私はまだ失われています。PHPを使用して.Net Webサービスを使用する
私が呼び出しようとしているSOAPサービスは認証ヘッダを持っており、私の要求を認証する方法を見つけることができません。
私はphp-soapclientとNuSoapの両方を試しましたが、役立つサンプルコードはありません。だから、どんな助けも素晴らしいだろう。
以下は、SOAP 1.1要求と応答のサンプルです。
POST /OxiWalletService/Service.asmx HTTP/1.1
Host: 172.160.0.49
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/WS_GetData"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthHeader xmlns="http://tempuri.org/">
<UserName>string</UserName>
<Password>string</Password>
</AuthHeader>
</soap:Header>
<soap:Body>
<WS_GetData xmlns="http://tempuri.org/">
<xmlString>string</xmlString>
</WS_GetData>
</soap:Body>
</soap:Envelope>
応答
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<WS_GetDataResponse xmlns="http://tempuri.org/">
<WS_GetDataResult>string</WS_GetDataResult>
</WS_GetDataResponse>
</soap:Body>
</soap:Envelope>
は誰でも、そのようなサービスを利用する方法について、サンプルコードを欲しがるてくださいすることができます。
事前に感謝します。
これは私がWebサービス
<?php
$soap_client = new SoapClient("http://172.160.0.49/OxiWalletService/Service.asmx?WSDL");
$Uid='oxigen';
$Pwd='oxigen';
$ns = "http://tempuri.org/";
//Body of the Soap Header.
$headerbody = array('UserName' => $Uid,
'Password' => $Pwd
);
//Create Soap Header.
$header = new SOAPHeader($ns, 'AuthHeader', $headerbody);
//set the Headers of Soap Client.
$soap_client->__setSoapHeaders($header);
$par="<Wallet><SPName>AuthenticateMerchantWebVending</SPName><Parameters><Parameter><Name>@Account</Name><Size>50</Size><Value>1135600016</Value><Type>varchar</Type></Parameter><Parameter><Name>@Password</Name><Size>20</Size><Value>0OgknrdonyM=</Value><Type>varchar</Type></Parameter></Parameters><ParameterCount>2</ParameterCount><DataBase>1</DataBase></Wallet>";
$param=array('xmlString'=>$par);
$result=$soap_client->__SoapCall('WS_GetData',$param);
print_r ($result);
?>
を呼び出すために使用していると私は出力として、次の取得していますコードです:
をはstdClassオブジェクト([WS_GetDataResult] => 2Unknownエラー)
アイデア??
だから、あなたがこの
$result=$soap_client->__SoapCall('WS_GetData',$param);
が
$result=$soap_client->__SoapCall('WS_GetData',array('parameters'=>$param));
これが機能するようになりましたする必要があります配列
意味のキーとしてパラメータを持つ第二引数を渡すためにしまし判明。
http://stackoverflow.com/questions/1581169/invoking-net-web-service-with-php – Arfeen
また、HTTPをチェック://チュートリアルのためのwww.scottnichol.com/nusoapprogwsdl.htm – Arfeen