[英]How to C# Soap Request Convert to PHP Code?
我正在嘗試將 SOAP 與 PHP 集成,但給出的示例是 C#。
我已經嘗試了很長時間,但我想我無法正確發送參數。
WSDL 地址: https : //betatest.elogo.com.tr/webservice/PostBoxService.svc?singlewsdl
示例 c# 代碼;
using (PostBoxService.PostBoxServiceClient svc = new PostBoxService.PostBoxServiceClient()) {
PostBoxService.LoginType login = new PostBoxService.LoginType();
login.userName = “test”;
login.passWord = “test”;
string sessionId;
if (svc.Login(login, out sessionId)) {
}
}
SOAP 請求示例
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/"
xmlns:efat="http://schemas.datacontract.org/2004/07/eFaturaWebService">
<soapenv:Header/>
<soapenv:Body>
<tem:Login>
<tem:login>
<efat:appStr></efat:appStr>
<efat:passWord>XXXXX</efat:passWord>
<efat:source></efat:source>
<efat:userName>XXXXX</efat:userName>
<efat:version></efat:version>
</tem:login>
</tem:Login>
</soapenv:Body>
</soapenv:Envelope>
我是 PHP 代碼;
$data = array(
'login' => array(
'userName'=>self::username,
'password'=>self::password
)
);
$client = new SoapClient(self::url,$client_params);
$client->Login($data);
它在 PHP 代碼中顯示以下錯誤;
[previous:Exception:private] =>
[faultstring] => String reference not set to an instance of a String.
Parameter name: s
[faultcode] => a:InternalServiceFault
[detail] => stdClass Object
(
[ExceptionDetail] => stdClass Object
(
[HelpLink] =>
[InnerException] =>
[Message] => String reference not set to an instance of a String.
Parameter name: s
[StackTrace] => at System.Text.Encoding.GetBytes(String s)
at CommonLib.Helper.HelperLib.ComputeMd5Hash(String input)
at CommonLib.Documents.LoginLogout.Login(LoginType login, String& sessionID)
at SyncInvokeLogin(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
[Type] => System.ArgumentNullException
)
)
非常感謝您的幫助。
您的示例 SOAP 請求顯示密碼密鑰是“passWord”(注意大寫 W),但在您的 PHP 中,您發送了“密碼”。 所以除了數據數組應該是:
$data = array(
'login' => array(
'userName'=>self::username,
'passWord'=>self::password
)
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.