Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP SOAP头与HTTP SOAP操作不匹配,如何设置?_Php_Soap_Soap Client_Soapheader - Fatal编程技术网

PHP SOAP头与HTTP SOAP操作不匹配,如何设置?

PHP SOAP头与HTTP SOAP操作不匹配,如何设置?,php,soap,soap-client,soapheader,Php,Soap,Soap Client,Soapheader,我什么都试过了!我正在使用它,只是想验证一下。我不断地发现这个错误: 消息“”上指定的SOAP操作与HTTP不匹配 SOAP操作,'http://tempuri.org/IPSShipCarrier/Authenticate" 这是我的密码: $options = array( "soap_version" => SOAP_1_2, "trace"=>1, 'UserName'=>'blahremoved',

我什么都试过了!我正在使用它,只是想验证一下。我不断地发现这个错误:

消息“”上指定的SOAP操作与HTTP不匹配 SOAP操作,'http://tempuri.org/IPSShipCarrier/Authenticate"

这是我的密码:

    $options = array(
        "soap_version" => SOAP_1_2,
        "trace"=>1,
        'UserName'=>'blahremoved',
        'Password'=>'blahremoved',
        'AuthToken'=>'blahremoved',
        'SOAPAction'=>'http://tempuri.org/IPSShipCarrier/Authenticate',
        'Action'=>'http://tempuri.org/IPSShipCarrier/Authenticate',
        'uri'=>'http://tempuri.org/IPSShipCarrier/Authenticate',
        'exceptions'=>true );

    $client = new SoapClient( "http://test.psdataservices.com/PSShipCarrierAPI/PSShipCarrier.svc?WSDL", $options );

    $auth = array(
        'UserName'=>'blahremoved',
        'Password'=>'blahremoved',
        'AuthToken'=>'blahremoved',
        'SOAPAction'=>'http://tempuri.org/IPSShipCarrier/Authenticate',
        'Action'=>"Authenticate"
    );
    $header = new SoapHeader('http://tempuri.org/IPSShipCarrier/Authenticate','Authenticate',$auth,false);

    $client->__setSoapHeaders($header);

    $params = new StdClass;
    $params->Action = "http://tempuri.org/IPSShipCarrier/Authenticate";
    $params->SOAPAction = "http://tempuri.org/IPSShipCarrier/Authenticate";
    $params->UserName = "blahremoved";
    $params->Password = "blahremoved";
    $params->AuthToken = "blahremoved";
$client->Authenticate($params);

让我知道您的想法?

为了解决内容类型标题问题,我将soap\u版本切换为soap\u 1\u 1

"soap_version" => SOAP_1_1,
然后我得到了一条更有趣的错误消息,Christian Burger用它来让我们更进一步地包含Shipcar参数

在此基础上,我查看了XSD,这里有一个更新的$params值,它起了作用:

$params->ShipCarr = 'scUnknown';
这返回:

POST /PSShipCarrierAPI/PSShipCarrier.svc HTTP/1.1
Host: test.psdataservices.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.8
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/IPSShipCarrier/Authenticate"
Content-Length: 856

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/" xmlns:ns2="http://tempuri.org/IPSShipCarrier/Authenticate"><SOAP-ENV:Header><ns2:Authenticate><item><key>UserName</key><value>blahremoved</value></item><item><key>Password</key><value>blahremoved</value></item><item><key>AuthToken</key><value>blahremoved</value></item><item><key>SOAPAction</key><value>http://tempuri.org/IPSShipCarrier/Authenticate</value></item><item><key>Action</key><value>Authenticate</value></item></ns2:Authenticate></SOAP-ENV:Header><SOAP-ENV:Body><ns1:Authenticate><ns1:UserName>blahremoved</ns1:UserName><ns1:Password>blahremoved</ns1:Password><ns1:AuthToken>blahremoved</ns1:AuthToken><ns1:ShipCarr>scUnknown</ns1:ShipCarr></ns1:Authenticate></SOAP-ENV:Body></SOAP-ENV:Envelope>
HTTP/1.1 200 OK
Content-Length: 325
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Mon, 25 Jun 2012 20:34:42 GMT
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><AuthenticateResponse xmlns="http://tempuri.org/"><AuthenticateResult i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/ShipCarriers.Contract" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/></AuthenticateResponse></s:Body></s:Envelope>
POST/PSShipCarrierAPI/PSShipCarrier.svc HTTP/1.1
主持人:test.psdataservices.com
连接:保持活力
用户代理:PHP-SOAP/5.3.8
内容类型:text/xml;字符集=utf-8
SOAPAction:“http://tempuri.org/IPSShipCarrier/Authenticate"
内容长度:856
用户名BlahreMovedPasswordBlahreMovedDauthTokenBlahreMovedSoapactionhttp://tempuri.org/IPSShipCarrier/AuthenticateActionAuthenticateblahremovedblahremovedblahremovedscUnknown
HTTP/1.1200ok
内容长度:325
内容类型:text/xml;字符集=utf-8
服务器:Microsoft IIS/7.5
X-Powered-By:ASP.NET
日期:2012年6月25日星期一20:34:42 GMT

但是,发出后续请求会导致500个内部服务器错误。

更改SOAP版本肯定会让您更进一步。但是,从堆栈跟踪来看,Authenticate方法似乎需要您未设置的参数。以下是您所需的最低代码,您不知道shipCarr对象应该是什么样子:

$options = array(
    "soap_version" => SOAP_1_1,
    "trace"=>1,
    'exceptions'=>true,
);

$client = new SoapClient( "http://test.psdataservices.com/PSShipCarrierAPI/PSShipCarrier.svc?WSDL", $options );

$params = new StdClass();
$params->UserName = "blahremoved";
$params->Password = "blahremoved";
$params->AuthToken = "blahremoved";
$params->ShipCarr = array();
$params->ClientName = "blahremoved";
$response = $client->Authenticate($params);
var_dump($response);
以下是回应:

[a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:ShipCarr. The InnerException message was 'Invalid enum value 'Array' cannot be deserialized into type 'ShipCarriers.Contract.scShipCarrier'. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.'.  Please see InnerException for more details.

当尝试访问一个未知的Web服务时,应该从soapUi开始。那会在2分钟内告诉你,那

这是一个SOAP1.1服务

这是身份验证端口的最小内容:


aat
soa
夸奥
韦拉奥拉斯
卑鄙小人
他们的messagerouter必须仅基于soap操作,因此使用操作是毫无意义和不必要的


所以,是的,使用soapUi可以节省您的时间;)

索皮岩,哈哈;我总是推荐它。
<tem:Authenticate>
     <!--Optional:-->
     <!--type: string-->
     <tem:ClientName>aat</tem:ClientName>
     <!--Optional:-->
     <!--type: string-->
     <tem:UserName>soa</tem:UserName>
     <!--Optional:-->
     <!--type: string-->
     <tem:Password>quaaao</tem:Password>
     <!--Optional:-->
     <!--type: string-->
     <tem:AuthToken>verraauras</tem:AuthToken>
     <!--Optional:-->
     <!--type: scShipCarrier - enumeration: [scUnknown,scStampsCom,scUPS,scEndicia,scFedEx]-->
     <tem:ShipCarr>scUnknown</tem:ShipCarr>
  </tem:Authenticate>