【问题标题】:Sending SOAP 1.2发送 SOAP 1.2
【发布时间】:2017-02-26 08:22:06
【问题描述】:

我必须使用 SOAP 将一些数据发送到服务器。我已经实现了这个,但我遇到了一个错误。

该错误不是 SOAP 或 PHP 等错误,而是由它们的应用程序协议导致的错误。

对方坚持认为是因为我发送的是 SOAP1.1 数据,而他们需要 SOAP1.2。据我所知,我正在发送 1.2。

为了检查我已经在我的服务器上创建了一个简单的页面来收集标题和数据,以便我可以看到实际发送的内容。

我是否遗漏了什么,或者根据我在下面发送的内容,这实际上是我怀疑的 SOAP1.2?

PS,我查看了这篇文章以获取有关差异的更多信息: http://wso2.com/library/articles/differentiating-between-soap-versions-looking-soap-message/ 谢谢一百万,

约翰

标题:

SERVER: Array
(
    [CONTENT_LENGTH] => 1286
    [CONTENT_TYPE] => application/soap+xml; charset=utf-8
    [DOCUMENT_ROOT] => /home/viewport/public_html
    [GATEWAY_INTERFACE] => CGI/1.1
    [GEOIP_ADDR] => 1.2.3.4
    [HTTP_ACCEPT] => */*
    [HTTP_EXPECT] => 100-continue
    [HTTP_HOST] => example.com
    [PATH] => /bin
    [QUERY_STRING] => 
    [REDIRECT_STATUS] => 200
    [REMOTE_ADDR] => 1.2.3.4
    [REMOTE_PORT] => 46608
    [REQUEST_METHOD] => POST
    [REQUEST_URI] => /soap/index.php
    [SCRIPT_FILENAME] => /home/example/public_html/soap/index.php
    [SCRIPT_NAME] => /soap/index.php
    [SERVER_ADDR] => 11.1.1.1
    [SERVER_ADMIN] => root@localhost
    [SERVER_NAME] => example.com
    [SERVER_PORT] => 80
    [SERVER_PROTOCOL] => HTTP/1.1
    [SERVER_SIGNATURE] => 
    [SERVER_SOFTWARE] => Apache
    [UNIQUE_ID] => WASuooHowGwAAFv9EK4AAAAB
    [PHP_SELF] => /soap/index.php
    [REQUEST_TIME] => 1476701858
)

和数据:

xml: <?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<EditionContactCustomer xmlns="http://tempuri.org/">
<Title>Spares</Title>
<FirstName>John</FirstName>
<Surname>Mc</Surname>
<AddressLine1></AddressLine1>
<PostTown>plett</PostTown>
<County>Western Cape</County>
<PostCode></PostCode>
<email>john@example.com</email>
<TelephoneNumber>081</TelephoneNumber>
<MobileNumber>081</MobileNumber>
<WorkTelephoneNumber></WorkTelephoneNumber>
<Notes>this is a test note.</Notes>
<ContactDate>2016-10-17</ContactDate>
<ContactTime>10:57:38</ContactTime>
<VehicleRecordID></VehicleRecordID>
<IntroductionSource>Existing</IntroductionSource>
<EnquirySource>WEB</EnquirySource>
<EnquiryType>WEB_FORM</EnquiryType>
<GUID></GUID>
<ReferenceID></ReferenceID>
<UserName></UserName>
<LinkUrl></LinkUrl>
<ImageData></ImageData>
</EditionContactCustomer>
</soap12:Body>
</soap12:Envelope>

【问题讨论】:

  • 你的实际 PHP 代码是什么?
  • 对不起,我忘了说我实际上并没有使用 SOAP 客户端。我只是创建 xml 然后使用 curl 发布它.. 上面的输出是 curl 发布的结果..
  • 但是.......为什么?

标签: php web-services curl soap


【解决方案1】:

要正确发送 SOAP 1.2,您需要在 SoapClient 构造中使用正确的“soap_version”参数。

$client = new SoapClient($url, array(
    "soap_version"      => SOAP_1_2,
    "login"             => "username",
    "password"          => "password"
));

其中 $url 是您的 WSDL 位置,在线或文件://

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多