Showing posts with label Connect. Show all posts
Showing posts with label Connect. Show all posts

Tuesday 30 August 2016

How to connect WSDL file with XML data with Basic Authentication in php

HTTP Auth works with SOAP Client, However you cannot access password protected WSDL files 

This is Simple example to auth webservice using soapClient
<?php
ini_set('display_errors', 1);
/*$client = new SoapClient('Materials_Availability.wsdl');
var_dump($client->__getFunctions());*/
$wsdl = "http://localhost/test/soap_wsdl/stock.wsdl?wsdl";
$client = new SoapClient($wsdl, array('login' => "******", 'password' => "******"));
echo ''.print_r($client,true).'';
$result = $client->__getFunctions();
echo '<pre>';print_r($result);
//$file = file_get_contents('soapxml.xml');
//echo $file;exit;
$array = array(
    'REQUEST'=> array(
        'MATERIALS'=> array(
                0=>array(
                    'MATERIAL_NUMBER'=>123654,
                    'MATERIAL_NUMBER_TYPE'=>'JAY',
                    'REQUEST_TYPE'=>array(
                        'TYPE'=>1
                    )
                ),
                1=>array(
                    'MATERIAL_NUMBER'=>654789,
                    'MATERIAL_NUMBER_TYPE'=>'JAM',
                    'REQUEST_TYPE'=>array(
                        'TYPE'=>2
                    )
                )
            )
        )
    );
print_r($array);
$result = $client->getMaterialAvailability($array);
print_r($result);
exit;
?>