Re: [SOAP] Cannot find encoding

[email protected] (Finn Gruwier Larsen) Mon, 09 May 2011 13:10:31 +0200
Newsgroups php.soap
Message-ID <[email protected]>
Den 09-05-2011 12:48, Richard Quadling skrev:
> On 9 May 2011 11:26, Finn Gruwier Larsen<[email protected]>  wrote:
>> Den 09-05-2011 12:14, Richard Quadling skrev:
>>>
>>> On 9 May 2011 11:12, Finn Gruwier Larsen<[email protected]>    wrote:
>>>>
>>>> Den 09-05-2011 12:01, Richard Quadling skrev:
>>>>>
>>>>> On 9 May 2011 09:52, Finn Gruwier Larsen<[email protected]>      wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am trying to get a SOAP request working. At this line in my code:
>>>>>>
>>>>>> $info = $soapClient->__call("getLegalUnit", array($ap_param));
>>>>>>
>>>>>> I get this error:
>>>>>>
>>>>>> PHP Fatal error:  SOAP-ERROR: Encoding: Cannot find encoding in<file>
>>>>>>   <line
>>>>>> no>.
>>>>>>
>>>>>> What does "encoding" mean in this context, and how do I specify it?
>>>>>>
>>>>>> Best regards,
>>>>>>
>>>>>> Finn
>>>>>>
>>>>>> --
>>>>>> PHP Soap Mailing List (http://www.php.net/)
>>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>>
>>>>>>
>>>>>
>>>>> What parameters do you pass to the SOAPClient constructor?
>>>>>
>>>>> http://docs.php.net/manual/en/soapclient.soapclient.php
>>>>>
>>>>> "The encoding option defines internal character encoding. This option
>>>>> does not change the encoding of SOAP requests (it is always utf-8),
>>>>> but converts strings into it."
>>>>>
>>>>> I use these options (amongst others) ...
>>>>>
>>>>>                                                 'encoding'  =>
>>>>>   'ISO-8859-1',
>>>>>                                                 'exception' =>      True,
>>>>>                                                 'trace'     =>      True,
>>>>>
>>>>> Richard.
>>>>>
>>>>
>>>> I only passed the "trace =>    True" parameter.
>>>>
>>>> Passing the extra parameters above does not change anything. I also tried
>>>> "encoding =>    'UTF-8'" with same result.
>>>>
>>>> Finn
>>>>
>>>
>>> Can you show more code?
>>>
>>
>> Sure.
>>
>> <?php
>> // Create private key:
>> $privateKey = openssl_pkey_new();
>>
>> // Create certificate signing request:
>> $csr = openssl_csr_new(array('http://...'), $privateKey);
>>
>> // Get public key:
>> $publicKey = openssl_csr_get_public_key($csr);
>> // print_r(openssl_pkey_get_details($publicKey));
>>
>> // Create SOAP client:
>> $params = array(
>>             'trace' =>  True,
>>             'encoding'  =>  'UTF-8',
>>             'exception' =>  True);
>> $soapClient = new SoapClient("LegalUnitGet_20080401.wsdl", $params);
>>
>> $ns = 'http://...';
>>
>> // Prepare SoapHeader parameters
>> $sh_param = array(
>>             'PrivateKey'    =>      $privateKey,
>>             'PublicKey'    =>       $publicKey);
>> $headers = new SoapHeader('http://...', 'Security', $sh_param);
>>
>> // Prepare Soap Client
>> $soapClient->__setSoapHeaders(array($headers));
>>
>> // Setup the RemoteFunction parameters
>> $ap_param = array(
>>             'LegalUnitIdentifier'     =>      'xxxxxx',
>>             'UserId'    =>      'xxxxx',
>>             'Password'    =>      'xxxxx');
>>
>> $info = $soapClient->__getFunctions();
>> print_r($info);
>>
>> // Call Remote Function ()
>> $error = 0;
>> try {
>>     $info = $soapClient->__soapCall("getLegalUnit", array($ap_param));
>> } catch (SoapFault $fault) {
>>     $error = 1;
>>     print("Faultcode: ".$fault->faultcode)."\n";
>>     print("Faultstring: ".$fault->faultstring);
>> }
>>
>> --
>>
>> Finn
>>
>
> Is the file and line in the file you've shown? As you are using Soap
> faults, is it possible that this is a server side error coming across
> in the soap fault?


I'm not quite sure I understand the first question - but the line in 
which the error occurs is ths one:

$info = $soapClient->__soapCall("getLegalUnit", array($ap_param));

It is not a server side error. I get the same error even if I leave out 
Soap faults. Besides, the server is a Java server and if I get errors 
from it, it will normally be in the shape of a Java stack trace.

Finn