views:

88

answers:

1

Any Suggestions Would be very helpful!

I need a little help getting a php client to connect to a .net WCF webservice and return a usercontext.

I can get it to work in .net but not php.

You have to sign in first which returns a usercontext that you pass to the other methods.

Developer Help: The UserContext property gets or sets the DCUserContext. Once SignIn is successful, a UserContext is assigned and every call made will need this UserContext.

the webservice wisdl is https://nspservices.natr.com/eCommerce/eCommerce.wsdl

I included the php code I am trying to use to return the usercontext that returns an erro and I included a sample of the VB.net code that does work.

:Testing PHP Code returns error

<?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();
}
?>

Response:

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 Code that works:

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)
A: 

Brian,

I think that $client->Signin(__ Parameters __); should work.

Justin Dearing
I am not sure I follow you.Brian
Brian Carver
I'm saying the soap object actually has a member names SignIn. I'm still working out the details myself. I need to setup fiddler to intercept the soap message I am sending.
Justin Dearing