Monday, April 30, 2018

PHP soap issues

Leave a Comment

Drupal 7-soap

This is the error which iam getting in error log and when iam trying to print the test.wsdl file

SoapFault: looks like we got no XML document in SoapClient->__call() 

enter image description here

I have no clue what is the error

My project environment

PHP : 5.4.11

MySQL : 5.5.27 Apache : 2.2.3

OS : CentOS 5.8

code information

function ai_server() {   ini_set('soap.wsdl_cache_ttl', 0);   $server = new SoapServer(file_create_url(variable_get('app_integration_wsdl')), array("trace" => 1, "exceptions" => 0));   $server->addFunction('getData');   $server->addFunction('getId');   $server->addFunction('getInfo');   $server->addFunction('getrightsInfo');   $server->addFunction('updateInfo');   $server->addFunction('resetAppHistory');   //$server->addFunction('resetAppId');    $server->handle(); } 

soap client

function ai_sync_test() {   ini_set('soap.wsdl_cache_ttl', 0); // // ---------------------------------------------------------------- basic tests //    // is settings file accessible   $settings_file = variable_get('app_integration_settings');   require_once($settings_file);   $settings_output = is_readable($settings_file) ? 'Ok! Settings file is readable.' : 'Error! Not readable or accessible.';    // is wsdl file accessible   $wsdl_file = variable_get('app_integration_wsdl');   $wsdl_output = is_readable($wsdl_file) ? 'Ok! WSDL file is readable. ' . l('Open it. ', $wsdl_file, array('attributes' => array('target' => '_blank'))) : 'Error! Not readable or accessible. ';   $wsdl_output .= 'You need to define domain name in it into this sections (at the bottom of app_integration.wsdl file): ';   $wsdl_output .= htmlentities('<soap:address location="http://YOUR_DOMAIN_HERE/app_integration/server"/>');    // methods, which integration service is provide   $client = new SoapClient($wsdl_file, array("trace" => 1, "exceptions" => 0));    $methods = $client->__getFunctions();   $methods_output = '';   foreach ($methods as $method) {     $methods_output .= '<li>' . $method . '</li>';   } 

1 Answers

Answers 1

2 possible reasons -

  1. You are echoing something in the code, or whitespace characters are getting printed or trailing new line character.

  2. The server SOAP file in php has encode utf8 with BOM, causing apache send back the BOM mark (3 bytes) before the xml response. Encode your php file soap server with utf8 WITH OUT BOM mark.

function strip_bom($str){     return preg_replace( '/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $str ); } 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment