php soapclient 异常,PHP SoapClient - 在错误的地方行动

我正在使用PHP SoapClient,并且遇到了与第三方需要的一样的请求格式问题。

他们想要这样:

POST /service.asmx HTTP/1.1

Host: service.com

Content-Type: application/soap+xml; charset=utf-8

Content-Length: length

string

然而,使用SoapClient最接近我看起来是这样的:

POST /service.asmx HTTP/1.1

Host: service.com

Content-Type: application/soap+xml; charset=utf-8; action="http://someservice"

Content-Length: length

string

请注意,我的请求中的操作是如何在http头中的,并且其理想格式的操作在Order标签中。问题是,SoapClient是在生成该动作的地方生成的 - 它从WSDL获取特定的URL,它甚至不在我的代码中。

我如何让SoapClient把它放在正确的位置?就我而言,试图只包括必要的东西,这实质上是代码:

$this->client = new SoapClient($this->wsdl, array(

'soap_version' => SOAP_1_2,

'encoding' => 'UTF-8',

'stream_context' => stream_context_create($context),

'trace' => true,

'exceptions' => true,

)

);

$json = json_encode($request);

// Prepare the xml

$xml = array();

$xml[] = new SoapVar($json, XSD_STRING, 'string', 'http://www.w3.org/2001/XMLSchema', 'json');

$this->finalXML = new SoapVar($xml, SOAP_ENC_OBJECT, null, null, 'Order');

$this->response = $this->client->CreateOrder($this->finalXML);

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值