2009-11-04 169 views
0

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

我可以让它在.net中工作,但不是PHP。

您必须首先登录,它会返回您传递给其他方法的usercontext。开发者帮助: UserContext属性获取或设置DCUserContext。一旦SignIn成功,一个UserContext被分配,每个调用都将需要这个UserContext。

web服务wisdl是https://nspservices.natr.com/eCommerce/eCommerce.wsdl

我包含在PHP代码我试图使用返回返回埃罗的的UserContext和我包括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) 
+0

你试过var_dump($ client);? – 2009-11-25 17:24:01

回答

0

Brian,

我认为$ client-> Signin(__ Parameters __);应该管用。

+0

我不知道我跟着你。 Brian – 2009-11-28 19:33:23

+0

我在说soap对象实际上有一个成员名SignIn。我仍然在自己制定细节。我需要设置小提琴来拦截我发送的肥皂信息。 – 2009-11-28 21:19:19

相关问题