需要有关PHP Client到.net WCF Web服务的帮助

时间:2009-11-04 17:04:38

标签: php wcf web-services

我需要一点帮助让php客户端连接到.net WCF webservice并返回usercontext。

我可以在.net中使用它而不是php。

您必须先登录,然后返回传递给其他方法的usercontext。

开发者帮助: UserContext属性获取或设置DCUserContext。一旦SignIn成功,就会分配一个UserContext,并且每次调用都需要此UserContext。

webservice wisdl是https://nspservices.natr.com/eCommerce/eCommerce.wsdl

我包含了我试图用来返回返回erro的usercontext的php代码,并且我包含了一个可以正常工作的VB.net代码示例。

:测试PHP代码会返回错误

<?php
$client = new SoapClient('https://nspservices.natr.com/eCommerce/eCommerce.wsdl');
echo '<pre>'; var_dump($client->__getFunctions()); echo '</pre><br /><br /><br />'; 
try
{
$client->__soapCall('Signin', 
    array(
        array('request' => 
            array(
                'UserName' => 'username',
                'ClientPassword' => 'password',
                'AccountNum' => 'accountnum',
                'NSPPassword' => 'password',
                'Language' => '1',
                'Market' => '1'
            ) 
        ) 
    )
);

}
catch (Exception $e)
{
    echo $e->getMessage();
}
?>

响应:

array(12) {
  [0]=>
  string(41) "SignInResponse SignIn(SignIn $parameters)"
  [1]=>
  string(65) "GetProductInfoResponse GetProductInfo(GetProductInfo $parameters)"
  [2]=>
  string(95) "GetProductsByFirstLetterResponse GetProductsByFirstLetter(GetProductsByFirstLetter $parameters)"
  [3]=>
  string(77) "GetProductSpecialsResponse GetProductSpecials(GetProductSpecials $parameters)"
  [4]=>
  string(41) "SignUpResponse SignUp(SignUp $parameters)"
  [5]=>
  string(53) "PlaceOrderResponse PlaceOrder(PlaceOrder $parameters)"
  [6]=>
  string(83) "GetGroupDownlineTreeResponse GetGroupDownlineTree(GetGroupDownlineTree $parameters)"
  [7]=>
  string(68) "GetOrderHistoryResponse GetOrderHistory(GetOrderHistory $parameters)"
  [8]=>
  string(47) "GetTotalResponse GetTotal(GetTotal $parameters)"
  [9]=>
  string(47) "GetTaxesResponse GetTaxes(GetTaxes $parameters)"
  [10]=>
  string(56) "GetShippingResponse GetShipping(GetShipping $parameters)"
  [11]=>
  string(113) "GetTrackingNumberByOrderNumberResponse GetTrackingNumberByOrderNumber(GetTrackingNumberByOrderNumber $parameters)"
}


Object reference not set to an instance of an object.

VB .net代码有效:

Imports nsgatewayvb.eCommerce

        ' extablish a procy to call the web service 
        Dim proxy As New IeCommerceClient()


        ' Sign into the service. All calls require a signin. The UserContext from the signin 
        ' is then passed to each subsequent call. The UserContext remains valid for 1 hour. 

        Dim s As DCSignIn = Helper.Signin(proxy, "username", "userpassword", "accountnum", "accountpassword")

        If s Is Nothing Then
            ' couldn't log in 
            Console.WriteLine("Unable to sign in to eCommerce system")
            Exit Sub
        End If

        If s.[Error] IsNot Nothing AndAlso s.[Error].ErrorNumber <> 0 Then
            Console.WriteLine("Error {0} : '{1}' during signup", s.[Error].ErrorNumber, s.[Error].Description)
            Exit Sub
        End If


        ' get product information 
        Helper.GetProductInfo(proxy, s.UserContext)

1 个答案:

答案 0 :(得分:0)

布赖恩,

我认为$ client-&gt; Signin(__ Parameters __);应该工作。