Search code examples
phpsoap-clientnusoapwsse

Nusoap PHP Client - Error 500


Hi i'm trying to get some data through a WSDL file using NuSoap.

the path to the wsdl file and the endpoint are below in the example.

So far what I have is the following:

try {
                require_once('../includes/nusoap/lib/nusoap.php');

                $wsdl = 'https://service.stadt-zuerich.ch/jobs-ws/JobServiceV1/JobServiceV1.wsdl';
                $endpoint = 'https://service.stadt-zuerich.ch/jobs-ws/JobServiceV1';
                $username = "xxx";
                $password = "xxx";

                $client = new nusoap_client($wsdl,true);

                $client->setEndpoint($endpoint);
                $client->namespaces = array(
                    'SOAP-ENV'=>"http://schemas.xmlsoap.org/soap/envelope/",
                    'v1'=>"http://egov.stzh.ch/jobs/service/v1"
                );
                $client->setHTTPEncoding ($enc='gzip, deflate');
                $client->loadWSDL();
                $client->soap_defencoding = 'utf-8';

                $header = '<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-secext-1.0.xsd">
                    <wsse:UsernameToken>
                        <wsse:Username>'.$username.'</wsse:Username>
                        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wssusername-token-profile-1.0#PasswordText">'.$password.'</wsse:Password>
                    </wsse:UsernameToken>
                </wsse:Security>';

                $call = 'getJobs';
                $param = array();       
                $result = $client->call($call,$param,'','',$header);

                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>';

            } catch (SoapFault $e) {
                die($e->getMessage());
            }

The problem is that I'm getting an Internal Server Error 500 when trying to get the data. The Password and Username are correct (tried with the SoapUI App and there I'm getting all the data.)

For the User and Password I tried to set a SoapHeader like in the example above and I also tried with the following, both not working.

$client->setCredentials($username,$password,'basic');

The endpoint should also be correct and I get the same header as the SoapUI app. I can't think of any other problems or solutions.

This is my Soap request:

<?xml version="1.0" encoding="utf-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://egov.stzh.ch/jobs/service/v1"> <SOAP-ENV:Header> <wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-secext-1.0.xsd"> <wsse:UsernameToken> <wsse:Username>xxx</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wssusername-token-profile-1.0#PasswordText">xxx</wsse:Password> </wsse:UsernameToken> </wsse:Security> </SOAP-ENV:Header> <SOAP-ENV:Body> <getJobs xmlns="http://egov.stzh.ch/jobs/service/v1"></getJobs> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

and this one my Soap response:

HTTP/1.1 500 Internal Server Error
Date: Mon, 02 May 2016 16:42:52 GMT
Server: Entry Server
Last-Modified: Wed, 20 Jan 2016 15:39:36 GMT
ETag: "9ed-f19-529c5cb14fe00"
Accept-Ranges: bytes
Content-Length: 3865
Content-Type: text/html
Set-CookieSCDID_S=Zp0F6_uw2M4ClToXcA9L4bu6oav0UeSztcleiUXqkuT8XUl2mDBu1w$$; path=/;     Secure
Connection: close

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">
<head>
<title>Stadt Z&uuml;rich: Interner Verarbeitungsfehler (Error 500)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
</head>

Does anyone has any idea what I'm doing wrong? I appreciate every help since I'm sitting for hours on that problem.

Thank you very much


Solution

  • What version of PHP are you using? I think nusoap does not support PHP 7, and I'm also 500 errors when trying to run nusoap on a server with PHP 7.