php soapclient 参数,php 使用soap 协议, client 无法传递参数到server

问题描述

最近在对接马来西亚的移动支付ipay88,ipay88支付平台使用的是soap+xml协议, 这个协议有点难懂,试了很久,都无法用php调试通过,用client 发出请求后,无法收到server的回复。

问题出现的环境背景及自己尝试过哪些方法

背景

开发语言: php

soap库文件: php官方的soap扩展包。

支付接口的调用地址: https://payment.ipay88.com.my/ePayment/WebService/MHGatewayService/GatewayService.svc

尝试过的内容

平台无法提供任何开发语言的demo,没有代码可以参考。

可以使用soapUI 来发出请求和返回。在这个工具中,发出请求是成功的。因此可以判断server端是正常工作的。

客户端尝试使用SoapClient的实例,调用了__getFunctions, 可以得到正常的函数返回值,因此可以判断php的soapclient的构造没有问题.测试结果如下:

request请求

$client = new SoapClient($location,$options);

$client->__getFunctions();

response返回

[

"EntryPageFunctionalityResponse EntryPageFunctionality(EntryPageFunctionality $parameters)",

"EntryPageFunctionalityResponse EntryPageFunctionality(EntryPageFunctionality $parameters)"

]

4.但是调用server端的函数时,失败了,php代码运行超时。我理解是__soapCall的调用参数没有写对,导致服务器接口没有返回导致的。

$result = $client->__soapCall(

'EntryPageFunctionality',$params,

[

'soapaction'=>'https://www.mobile88.com/IGatewayService/EntryPageFunctionality',

]

);

echo json_encode($result);

请求失败的原因,目前猜测,有两个可能的原因

这个支付接口使用的是wsdl文件, 但是这个wsdl下有两个web service, 一个webservice是http协议,还有一个webservice是https协议。我可能调用到了http协议的那个webservice。但是不知道应该如何设置__soapCall方法的参数,来调用到https协议的webservice。

传递过去的参数中,key值的格式有问题。不是我代码中'requestModelObj'这样的格式,而是其他的形式。

6f82bd9b258433b7552762aa7471e0bb.png

相关代码

平台给的示例数据

#raw data:

POST https://payment.ipay88.com.my/ePayment/WebService/MHGatewayService/GatewayService.svc HTTP/1.1

Accept-Encoding: gzip,deflate

Content-Type: text/xml;charset=UTF-8

SOAPAction: "https://www.mobile88.com/IGatewayService/EntryPageFunctionality"

Content-Length: 2313

Host: payment.ipay88.com.my

Connection: Keep-Alive

User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

#request data xml:

0.01

281001023704034671047838

MYR

M15137

0

ali

alipay129

50a44ae179468a94b092a7ed90bdfd40927de61c380bc019987d7055ec86259d

SHA256

01234567890

ss@email.com

SS

UTF-8

​#response data xml:

00000000-0000-0000-0000-000000000000

0.01

0.01

MYR

0

0.00

M15137

234

alipay129

de2916cbd8de8833c11febd9cb62f1aa5f6966a21ddf56df088bf1bd02e30dd5

1

T007920326120

php测试代码

try {

$location = 'https://payment.ipay88.com.my/ePayment/WebService/MHGatewayService/GatewayService.svc?wsdl';

$options = array(

'stream_context' => stream_context_create([

'http'=> [

'header' => "Accept-Encoding: gzip,deflate\r\n

Content-Type: text/xml;charset=UTF-8\r\n

Host: payment.ipay88.com.my\r\n

Connection: Keep-Alive\r\n

user_agent: PHP/SOAP client"

],

])

);

$client = new SoapClient($location,$options);

$params = [

'requestModelObj' => [

'ActionType' => '',

'Amount' => '1.00',

'BackendURL' => '',

'BarcodeNo' => '18599882',

'CCCId' => '',

'CCCOriTokenId' => '',

'CCMonth' => '',

'CCName' => '',

'CCNo' => '',

'CCYear' => '',

'CVV2' => '',

'Currency' => 'MYR',

'DiscountedAmount' => '0',

'MTLogId' => '',

'MTVersion' => '',

'MerchantCode' => 'M15137',

'PaymentId' => 0,

'ProdDesc' => 'Product Service',

'PromoCode' => 'Product Service',

'RefNo' => 'XS-7357-2633202003123133156',

'Remark' => '',

'Signature' => 'fea2a5adcfc0298678577e34bf04793527b94e1ea045305ca43e43eaad309bb9',

'SignatureType' => 'SHA256',

'TerminalID' => '',

'TokenId' => '',

'UserContact' => '18668067622',

'UserEmail' => 'yiming@91laiqian.com',

'UserName' => 'sabao',

'forexRate' => '',

'lang' => 'UTF-8',

'xfield1' => '',

'xfield2' => '',

]

];

$result = $client->__soapCall(

'EntryPageFunctionality',$params,

[

'soapaction'=>'https://www.mobile88.com/IGatewayService/EntryPageFunctionality',

]

);

echo json_encode($result);

} catch (\SoapFault $e) {

echo $e->getMessage();

}

你期待的结果是什么?实际看到的错误信息又是什么?

期待结果: response 返回xml格式的字符串。

实际情况: php代码运行超时, 应该是接口迟迟没有返回,导致超时。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值