3

I am still very new to use php to call the SoapClient. Recently I have a project which I need to call the API from .net using web service SOAP.

I won't able to see the actual XML code of the web service URL provided as it requires header to access, therefore test via POSTMAN, it works well.

However, it doesn't work when using php to call their web service on the localhost server (XAMPP), (other web service address work fine on the code below), not sure where it goes wrong:

  $Auth = array(

    'Content-Type' => 'text/xml',
    'X-RW-Auth-Token' => '4f931e62-d8c8-439b-a4d7-0c29fc0e3dbe'

);

$client = new SoapClient("https://licensed-ws.ricewarnerdigital.com/process/RiskEngine/v1.0/EndPoint.asmx?wsdl");

$header = new SoapHeader(url,null, $Auth,false);

$client->__setSoapHeaders($header);

$param = array(
    'RR_AgeNext' => '30',
    'RR_TermSI' => '1000000',
    'RR_TPDSI' => '3000000',
    'RR_AnyOwn' => 'A'
);

$GetResponse = $client->GetQuotationsForParameters($param);

Error:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '...' : failed to load external entity "..." in /Applications/XAMPP/xamppfiles/htdocs/quote-tool/ricewarner_api.php:11 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/quote-tool/ricewarner_api.php(11): SoapClient->SoapClient('https://license...') #1 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/quote-tool/ricewarner_api.php on line 11

10
  • Please post the relevant portions of your WSDL. I cannot access the URL in your code. Commented Aug 13, 2015 at 6:54
  • It's the only URL provided by the API company, the support said that it has to send with the header info in order to access...if you use postman, with the header provided, it will work but not on the php. Thanx Commented Aug 13, 2015 at 7:16
  • My first guess is that your SOAP envelope has a problem. This is why I asked for the WSDL. Commented Aug 13, 2015 at 7:18
  • The SOAP envelope itself has no problem, because tested on the postman it responsed. It has to do with header X-RW-Auth-Token and Content-Type that need to associate with the envelope together post the request. but not sure why the code isn't working... Commented Aug 13, 2015 at 7:30
  • Please post your <soapenv:Header> tag. I'm afraid without this, we cannot help you. Commented Aug 13, 2015 at 7:51

1 Answer 1

0

I finally get it to work, eventually the SoapClient couldn't work with the web service which contain licensing layer so I have to use CURl to call. Below is the code:

class GetPremiumData{

        public function doXMLCurl($url,$postXML){

        $CURL = curl_init();

        curl_setopt($CURL, CURLOPT_URL, $url); 
        curl_setopt($CURL, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
        curl_setopt($CURL, CURLOPT_POST, 1); 
        curl_setopt($CURL, CURLOPT_POSTFIELDS, $postXML); 
        curl_setopt($CURL, CURLOPT_HEADER, false); 
        curl_setopt($CURL, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($CURL, CURLOPT_HTTPHEADER, array('Content-Type: text/xml','X-RW-Auth-Token: apiToken'));
        curl_setopt($CURL, CURLOPT_RETURNTRANSFER, true);

        $xmlResponse = curl_exec($CURL);

        return $xmlResponse;
    }

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.