Hi All

I am very much new to PHP and facing the problem like below.

I am facing problem in calling WCF Service from PHP using SoapClient along with network credentials.

Used below code to get the results from WCF service and getting the error copied below the code. Please help me in this Regard. thanks in advance for your help

Code

$client = new SoapClient("https://api.xdpart.net/CMAPI_SANDBOX/V1_1/SOAP/App.svc?wsdl");

$sh_param = array( 'UserName' => 'xdpartAPI@satya.com',
'Password' => 's@vas');

$headers = new SoapHeader('https://api.xdpart.net/CMAPI_SANDBOX/V1_1/SOAP/App.svc', 'UserCredentials', $sh_param);

$client->__setSoapHeaders(array($headers));
$answer = $client->GetAdvertisers();

Results

Fatal error: Uncaught SoapFault exception: [HTTP] Unauthorized in C:\wamp\www\ADVT\AppCall.php:22 Stack trace: #0 [internal function]: SoapClient->doRequest('<?xml version="...', 'https://api.dtp...', 'http://tempuri....', 1, 0) #1 [internal function]: SoapClient->call('GetAdvertisers', Array) #2 C:\wamp\www\ADVT\AppCall.php(22): SoapClient->GetAdvertisers() #3 {main} thrown in C:\wamp\www\ADVT\AppCall.php on line 22

Once again thanks in advance for your help

Satya

    Please use [php] and [/php] for your PHP code, it helps keep ti cleanly formatted.

    try making this change:

    $headers = new SoapHeader('https://api.xdpart.net/CMAPI_SANDBOX/V1_1/SOAP/App.svc', 'UserCredentials' => $sh_param); 
    

    Otherwise, you will have to provide an example successful SOAP request so that we can help you build the headers.

    Please post as much info as possible.

      3 months later

      Hi,

      I know almost nothing of PHP but I am trying to build a small client to call a WCF service... I am facing difficulty in understanding how to build my request and pass it to the service. The request is composed of objects type defined in the enroll method of my service...

      Can anyone point me to some documentation that could assist me? Anythign would be so appreciated!

      Thanks!

        Write a Reply...