0

I need some help

I have to connect a SOAP webservice, using PHP

I have the service, something like this: http://xxx/xxx/Servicios?wsdl (real url is hidden) I have an user and password for this

A method is implemented (by other team), SelectLectores, and request is something like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="http://xxxxxxxxx">
        <soapenv:Header>
         <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
           <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
             <wsse:Username>myuser</wsse:Username>
             <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">mypassword</wsse:Password>
           </wsse:UsernameToken>
         </wsse:Security>
       </soapenv:Header>
   <soapenv:Body>
      <impl:selectLectores>
         <arg0>
            <!--Mandatory:-->
            <centro>51000286</centro>
            <!--Optional:-->
            <codigoLector>14103</codigoLector>
         </arg0>
      </impl:selectLectores>
   </soapenv:Body>
</soapenv:Envelope>

Im using this code to connect in php:

$service="http://xxx/xxx/Servicios?wsdl";
$param=array();
$param['centro']=51000286;
$validation= array(
'Username' => 'myuser',
'Password' => 'mypassword'
);

$client = new SoapClient($service,$validation);
$result = $client->selectLectores($param);

But doesn´t work, shows this error: 500 | Internal Server Error | SoapFault java.lang.NullPointerException

Im doing something wrong?

Alex
  • 9
  • 1
  • Seems like an error in the server side (I guess it's a Java web service). Are you able to test the web service with an external tool (not your php client)? Also what you can try is print the whole result in your case `var_dump($result);` taht should print some more debug informations. – xander Aug 10 '17 at 09:26
  • I have tried to print $result, but I can´t, should be empty or something But, is my code well done? – Alex Aug 10 '17 at 10:23
  • I just noticed your login data might be wrong, can you try it with `$validation= array( 'login' => 'myuser', 'password' => 'mypassword' );` instead of `username`. You should still test the soap webservice, I can recommend [SoapUI](https://www.soapui.org/) for that. – xander Aug 10 '17 at 10:56
  • No, same result, "java.lang.NullPointerException" :( – Alex Aug 10 '17 at 10:58
  • Other team has told me, checking them logs, Im sending the header empty. How send with user a pass data? – Alex Aug 11 '17 at 07:48
  • It should be handled by `SoapClient`, but you can check the output it's generating, look at this question: https://stackoverflow.com/questions/14030228/how-to-dump-soapclient-request-for-debug – xander Aug 11 '17 at 07:51

0 Answers0