Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username='xxx';
- $password='yyy';
- $WSDL_URL='https://myserver.com/mywebservice?wsdl';
- $auth = base64_encode($username . ":" . $password);
- $Header = array(
- 'http'=>array(
- 'method'=> "POST",
- 'header'=> "Authorization: Basic $authrn".
- "Content-Type: text/xmlrn".
- "cache-control: no-cache"
- )
- );
- $HeaderContext = stream_context_create($Header);
- $soap = new SoapClient(NULL, array(
- 'login' => $username,
- 'password' => $password,
- 'trace' => 1,
- 'exceptions' => 0,
- 'location' => $WSDL_URL,
- 'uri' => $WSDL_URL,
- 'cache_wsdl' => WSDL_CACHE_NONE,
- 'stream_context' => $HeaderContext
- ));
- $response = $soap->serviceECHO( 'Hello' );
- print_r($response);
- $username='xxx';
- $password='yyy';
- $WSDL_URL='https://myserver.com/mywebservice?wsdl';
- $auth = base64_encode($username . ":" . $password);
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => $WSDL_URL,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => "
- <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:uet='http://myserver.com/'>
- <soapenv:Header/>
- <soapenv:Body>
- <uet:testMsj>Hello</uet:testMsj>
- </soapenv:Body>
- </soapenv:Envelope>",
- CURLOPT_HTTPHEADER => array(
- "Content-Type: text/xml",
- "cache-control: no-cache",
- "Authorization: Basic $auth"
- ),
- ));
- $xmlResponse = curl_exec($curl);
- print_r($xmlResponse);
Add Comment
Please, Sign In to add comment