On 9 May 2011 11:48, Richard Quadling <rquadling@gmail.com> wrote: > On 9 May 2011 11:26, Finn Gruwier Larsen <finn@gruwier.dk> wrote: >> Den 09-05-2011 12:14, Richard Quadling skrev: >>> >>> On 9 May 2011 11:12, Finn Gruwier Larsen<finn@gruwier.dk> Âwrote: >>>> >>>> Den 09-05-2011 12:01, Richard Quadling skrev: >>>>> >>>>> On 9 May 2011 09:52, Finn Gruwier Larsen<finn@gruwier.dk>  Â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? > -- > Richard Quadling > Twitter : EE : Zend > @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY > In looking at the possible cause of the error. The error is caused by a failure in a hash lookup in the function get_conversion() (php_encoding.c) In tracking that back to the callee for the function, the sort of calls being made are NOT to do with character encoding, but type encoding. e.g. Windows Grep Search Results 'get_conversion' in *.*: 33 matches in 5 files. 677 files searched. 0 files skipped. Plain | File contents à | File names à | Line numbers à | Whole line à | Word wrap | Fixed Font | Match window: +/- 0à | 1 | 2 | 3 | 4 | 5 lines D:\BuildPHP\php53dev\vc9\x86\PHP_5_3\ext\soap\php_encoding.c 00403: enc = get_conversion(Z_LVAL_P(*ztype)); 00471: encode = get_conversion(UNKNOWN_TYPE); 00561: encode = get_conversion(UNKNOWN_TYPE); 01277: zval* val = master_to_zval(get_conversion(XSD_ANYXML), node); 01296: zval* val2 = master_to_zval(get_conversion(XSD_ANYXML), node->next); 01767: enc = get_conversion(XSD_ANYXML); 02042: property = master_to_xml(get_conversion((*zprop)->type), (*zprop), style, xmlParam); 02075: enc = get_conversion(APACHE_MAP); 02077: enc = get_conversion(SOAP_ENC_ARRAY); 02081: enc = get_conversion(IS_NULL); 02204: xparam = master_to_xml(get_conversion((*zdata)->type), (*zdata), style, xmlParam); 02805: xparam = master_to_xml(get_conversion((*temp_data)->type), (*temp_data), style, item); 02868: enc = get_conversion(data->type); 02870: enc = get_conversion(IS_NULL); 02892: enc = get_conversion(IS_NULL); 02894: enc = get_conversion(IS_NULL); 02926: enc = get_conversion(SOAP_ENC_ARRAY); 02928: enc = get_conversion(XSD_STRING); 02932: enc = get_conversion(SOAP_ENC_OBJECT); 03223: encodePtr enc = get_conversion(XSD_ANYXML); 03581: encodePtr get_conversion(int encode) 03621: return get_conversion(XSD_ANYTYPE); 03683: return get_conversion(XSD_ANYTYPE); 03707: enc = get_conversion(cur_type); D:\BuildPHP\php53dev\vc9\x86\PHP_5_3\ext\soap\php_encoding.h 00208: encodePtr get_conversion(int encode); D:\BuildPHP\php53dev\vc9\x86\PHP_5_3\ext\soap\php_packet_soap.c 00194: zval *zv = master_to_zval(get_conversion(IS_STRING), tmp); 00201: zval *zv = master_to_zval(get_conversion(IS_STRING), tmp); 00224: zval *zv = master_to_zval(get_conversion(IS_STRING), tmp); D:\BuildPHP\php53dev\vc9\x86\PHP_5_3\ext\soap\php_schema.c 02210: type->encode = get_conversion(XSD_ANYXML); D:\BuildPHP\php53dev\vc9\x86\PHP_5_3\ext\soap\soap.c 01137: enc = get_conversion(UNKNOWN_TYPE); 04130: xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, param); 04134: xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, param); 04156: node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, node); So, it looks more like the client is sending a type that no map exists for. At a guess. Can you provide the URL for the wsdl file? Alternatively, take a look at the some of my comments on this list at http://news.php.net/php.soap for a different way to use SOAP services in PHP (well, slightly different). The main concept is to hide the SOAP nature and provide local classes which act as proxies for the soap transaction. So, on the client, it looks like normal OOP classes. No XML. No SOAP. No HTTP. Richard. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php