NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
PHP and WSDL


Joined: 09 Sep 2008
Posts: 3
Reply with quote
Hi,

I'm trying to use a WSDL webservices but I'm new to the whole thing. I have used PHP on a few sites but never to call a webservices.

I'm helping other to use one that is avaliable by a company. I got the required login information, the url to the WSDL and I got info about the function. But I can't get the whole thing to work.

The HelloWorld function is just used to check and see if the webservices connection is a success, all it do is to return the string that you give it.

This is the code:

Code:

<HTML>
<HEAD>
 <TITLE>AFSWS Test</TITLE>
</HEAD>
<BODY>
<?
/*
 *   $Id: wsdlclient3.php,v 1.4 2007/11/06 14:48:49 snichol Exp $
 *
 *   WSDL client sample.
 *
 *   Service: WSDL
 *   Payload: rpc/encoded
 *   Transport: http
 *   Authentication: none
 */
 
 echo '<h1>PHP koppling till AFSWS WSDL Test</h1><br>';

require_once('../lib/nusoap.php');
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$client = new nusoap_client('http://testhorizon.gothiagroup.com/AFSServices/AFSService.svc?wsdl', 'wsdl',
                  $proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
   echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}

$inTest = array('myValue' => "Hello Exor");
$result = $client->call('HelloWorld', array('myValue' => $inTest));


// Check for a fault
if ($client->fault) {
   echo '<h2>Fault</h2><pre>';
   print_r($result);
   echo '</pre>';
} else {
   // Check for errors
   $err = $client->getError();
   if ($err) {
      // Display the error
      echo '<h2>Error</h2><pre>' . $err . '</pre>';
   } else {
      // Display the result
      echo '<h2>Result</h2><pre>';
      print_r($result);
      echo '</pre>';
   }
}
//echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
//echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
//echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>
</BODY>
</HTML>


But I get an error:

Error
HTTP Error: Unsupported HTTP response status 415 Cannot process the message because the content type 'text/xml; charset=ISO-8859-1' was not the expected type 'text/xml; charset=utf-8'. (soapclient->response has contents of the response)

If I get the webservices to work correctley I can go from there and build the functionallity of the page.

Any help is appreciated.
View user's profileFind all posts by celledorSend private message


Joined: 09 Sep 2008
Posts: 3
Reply with quote
A simpler side question how do I change the encoding from ISO-8859-1 to UTF-8? This seems to be the problem behind the error.

I tested the webservice using soapUI 2.0.2 and it works just fine, so the problem is the code.
View user's profileFind all posts by celledorSend private message


Joined: 09 Sep 2008
Posts: 3
Reply with quote
I have solved this problem (int the nusoap.php file this could changed) but eucountered another problem, this is what I need to do to solve it:

I need to change the request from this:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns8867="http://tempuri_org">
<SOAP-ENV:Body>
<GetCustomer xmlns="http://tempuri_org/">
<user>
<Username>aaaaa</Username>
<Password>xxxxxx</Password>
<ClientID>1111</ClientID>
</user>
<customerNo>1</customerNo>
<orgno/>
<firstname/>
<lastname/>
<ssn/>
<bornDate/>
<address/>
<postalCode/>
<postalPlace/>
<countryCode/>
</GetCustomer>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


To this:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns8867="http://tempuri_org"
xmlns:akt="http://AktivKapital.ExternalServices">
<SOAP-ENV:Body>
<GetCustomer xmlns="http://tempuri_org/">
<user>
<akt:Username>aaaaa</akt:Username>
<akt:Password>xxxxxx</akt:Password>
<akt:ClientID>1111</akt:ClientID>
</user>
<customerNo>1</customerNo>
<orgno/>
<firstname/>
<lastname/>
<ssn/>
<bornDate/>
<address/>
<postalCode/>
<postalPlace/>
<countryCode/>
</GetCustomer>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


How do I in the nusoap php code add the akt: from xmlns:akt="http://AktivKapital.ExternalServices"> to the user?
View user's profileFind all posts by celledorSend private message
PHP and WSDL
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic