Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Problem with WS response content-type

Help
Anonymous
2012-02-16
2013-06-06

  • Anonymous
    2012-02-16

    Hello,

    We have a service to connect to another service that it response and XML into ISO-8859-1, but we need response to our customer like a UTF-8 content-type, I paste a part of the code from de WS, and mistake that appear into the client.

             $clientALZ = new nusoap_client($PathWSDL, 'wsdl');
             $clientALZ->URL = $URLConnect;
             $err = $clientALZ->getError();
             if($err)
             {
               $OKGrabar = GrabarXML("Certificado: Constructor error \r\nError: $err \r\nXMLDialog FIN \r\n" , '\\XMLDialog');
               return new soapval('return',
                                               'xsd:string',
                                               '<Error><type>Constructor error</type><err>' . $err . '</err></Error>' );
             }
             $result = $clientALZ->call("$FunctionConnect",
                                                       array("$ParamXMLsend"=>$XMLenvio));

              /* put result 3 like example to test the answer to the client */                          
             $result3 = '<?xml version="1.0" encoding="UTF-8"?>';
             $result3 .= "<DataVehiclesResponse>";
             $result3 .= "<ReturnCode>0</ReturnCode>";
             $result3 .= "<ReturnText/>";
             $result3 .= "<ReturnPgr>DataVehiclesService</ReturnPgr>";
             $result3 .= "<ManufacturerContainer>";
             $result3 .= "<Manufacturer>ABARTH</Manufacturer>";
             $result3 .= "<Manufacturer>ACE</Manufacturer>";
             $result3 .= "<Manufacturer>ACM</Manufacturer>";
             $result3 .= "<Manufacturer>ADRIA</Manufacturer>";
             $result3 .= "</ManufacturerContainer>";
             $result3 .= "</DataVehiclesResponse>";
             header('Content-Type: text/html; charset=utf-8');
            
             $result3 = iconv('ISO-8859-1', 'UTF-8', $result3);

    return new soapval('return',
                                    'xsd:string',
                                    implode(" ",utf8_encode($result3) ) );
            ________________________________________________________

    Into the client appear this mistake:

    The content type text/xml; charset=ISO-8859-1 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 457 bytes of the response were: '<?xml version="1.0" encoding="ISO-8859-1"?><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/"><SOAP-ENV:Body><ns1:getAlz2Response xmlns:ns1="http://mydomain.es/Webservice2/WinPhone.php"><return/></ns1:getAlz2Response></SOAP-ENV:Body></SOAP-ENV:Envelope>'.

    How We can send a full UTF-8 SOAP-ENV?

    Thanks