PHP Soap Client-发送错误的标头"soapenv:VersionMismatch"; [英] PHP Soap Client - sending the wrong headers "soapenv:VersionMismatch"

查看:835
本文介绍了PHP Soap Client-发送错误的标头"soapenv:VersionMismatch";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个无法解决的问题.我已经在php中创建了一个肥皂客户端,该客户端应该向Web服务发出xml请求-该服务正在通过SoapUI工作,但是每当我通过php客户端发送相同的请求时,我都会收到以下错误代码:

I've come across a problem that I cannot figure out how to fix. I've created a soap client in php that is supposed to do an xml request to a web service - the service is working through SoapUI, but whenever I send the same request through my php client I get the following faultcode:

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <soapenv:Fault>
      <faultcode>**soapenv:VersionMismatch**</faultcode>
      <faultstring>**Transport level information does not match with SOAP Message namespace URI**</faultstring>
      <detail></detail>
    </soapenv:Fault>
  </soapenv:Body>
</soapenv:Envelope>

现在,客户端和服务都正在使用soap版本1.2,我相信问题出在客户端上,因此这是我的定义方式:

Now, both the client and the service are working with soap version 1.2, I believe that the problem is in the client, so here it is how I've defined it:

$options  = array(
    'trace'        => true, 
    'exceptions'   => 1, 
    'style'        => SOAP_DOCUMENT,
    'use'          => SOAP_LITERAL,
    'soap_version' => SOAP_1_2,
);
$client = new SoapClient("location_of_the_wsdl", $options);

在请求中,我使用以下代码:

In the request I'm using the following code:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <env:Header/>
   <env:Body>
      <ns2:FunctionName xmlns:ns2="namespace_of_the_service">
         <arg0>
              <data1>?</data1>
           </arg0>
       </ns2:FunctionName>
   </env:Body>
</env:Envelope>

在soapUI中,这给我一个假"结果,因为data1保留了?,当我写入有效数据时,它返回true.

In soapUI this is giving me a 'false' result as the data1 is left with ?, when I write in valid data it returns true.

我还注意到,在soapUI中,我正在发送和接收内容类型application/soap+xml,但是当我通过PHP客户端进行操作时,我会发送和接收内容类型text/xml的标头;

I've also noticed that in soapUI I'm sending and receiving the Content-type application/soap+xml, but when I'm doing it through the PHP client I send and receive headers with Content-Type text/xml;

可能是什么问题?我将nusoap.php用于客户端.

What could be the problem? I use nusoap.php for the client.

推荐答案

请确保通过设置在开发(测试)计算机的php.ini文件中禁用了 WSDL缓存功能

Make sure the WSDL caching feature is disabled in php.ini file of your development (test) machine by setting

soap.wsdl_cache_enabled=0 

仅因为缓存了WSDL,我才在这个问题上存了超过1天的时间:

I got stocked in this problem for more than 1 day only because of cached WSDL :)

这篇关于PHP Soap Client-发送错误的标头"soapenv:VersionMismatch";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆