PHP使用.net服务

时间:2016-12-11 16:35:14

标签: php web-services soap

所以我有

上的以下网络服务

http://screencast.com/t/y8qM8hRDu

这些是我的试验和结果:

尝试1:

    $api_target = "http://www.xyz.co/service1.svc?wsdl"
    $soap_options["location"] = $api_target;
    $soap_options['trace'] = TRUE;
    $soap_options['cache_wsdl'] = WSDL_CACHE_NONE;
    $soap_options['style'] = SOAP_RPC;
    $soap_options['use'] = SOAP_ENCODED;
    $soap_options['soap_version'] = SOAP_1_2;

    $client = new SoapClient($api_target,$soap_options);
    $result = $client->Login(array("parameters" => $user));

回复1:

The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://tempuri.org/IService1/Login'.

尝试2:添加了SOAPaction标头

    $actionHeader = new SoapHeader($api_target,'SOAPAction','http://tempuri.org/IService1/Login');
    $client->__setSoapHeaders($actionHeader);

    $client = new SoapClient($api_target,$soap_options);
    $result = $client->Login(array("parameters" => $user));

回复2:: 错误的要求

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

通过一些无法解释的奇迹,我得到它的工作,如果它帮助这里的任何人是修改代码

$api_target = "http://www.xyz.co/service1.svc";
$api_url = $api_target."?wsdl";
$action = "http://tempuri.org/IService1/Login";

$soap_options["location"] = $api_target;
$soap_options["uri"] = $api_url;
$soap_options['trace'] = TRUE;
$soap_options['cache_wsdl'] = WSDL_CACHE_NONE;
$soap_options['style'] = SOAP_DOCUMENT;
$soap_options['use'] = SOAP_LITERAL;
$soap_options['soap_version'] = SOAP_1_2;

$actionHeader[] = new SoapHeader('http://www.w3.org/2005/08/addressing','Action',$action , true);
$actionHeader[] = new SoapHeader('http://www.w3.org/2005/08/addressing','To',$api_target ,true);

$client = new SoapClient($api_url,$soap_options);
$client->__setSoapHeaders($actionHeader);

$result = $client->__soapCall('Login',array($user));;