Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

error 500

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All

I try make a request with JAVA HttpClient set body with a XML.



HttpClient httpClient1 = new HttpClient();
httpClient1.getParams().setParameter("http.useragent", "Web Service Test Client");

String data1 =

"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"; "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"; "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"; "
+ "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"; "
+ "xmlns:tns=\"http://sites.meucarronovo.com.br/web_services/registra_veiculo/serverV2.php\">";
+ "<soap:Body soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">";
+ "<tns:consultaModelosByMarca>"
+ "<token xsi:type=\"xsd:string\">"+token+"</token>"
+ "<marca_consulta xsi:type=\"xsd:string\">"+marcaEnvelope+"</marca_consulta>"
+ "<tipo_veiculo xsi:type=\"xsd:string\">AUTOMÓVEL</tipo_veiculo>"
+ "</tns:consultaModelosByMarca>"
+ "</soap:Body>"
+ "</soap:Envelope>";

System.out.println("Data .. "+data1);
PostMethod methodPost1 = new PostMethod("http://sites.meucarronovo.com.br/web_services/registra_veiculo/serverV2.php";);
methodPost1.setRequestBody(data1);
methodPost1.setRequestHeader("Content-Type", "text/xml");


int returnCode1 = httpClient1.executeMethod(methodPost1);
System.out.println("Return Code 1 = " +returnCode1);


When i run aplication :


Data .. <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:tns="http://sites.meucarronovo.com.br/web_services/registra_veiculo/serverV2.php"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><tns:consultaModelosByMarca><token xsi:type="xsd:string">bd3f5424</token><marca_consulta xsi:type="xsd:string">NISSAN</marca_consulta><tipo_veiculo xsi:type="xsd:string">AUTOMÓVEL</tipo_veiculo></tns:consultaModelosByMarca></soap:Body></soap:Envelope>


Return Code 1 = 500
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>Sender</faultcode><faultstring>Invalid XML</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

Root element .. :SOAP-ENV:Envelope
----------------------------

When copy DATA1 in SOAPSonar Personal 6 and run it its run ok :

Request :

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:tns="http://sites.meucarronovo.com.br/web_services/registra_veiculo/serverV2.php">;
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">;
<tns:consultaModelosByMarca>
<token xsi:type="xsd:string">bd3f5424</token>
<marca_consulta xsi:type="xsd:string">NISSAN</marca_consulta>
<tipo_veiculo xsi:type="xsd:string">AUTOMÓVEL</tipo_veiculo>
</tns:consultaModelosByMarca>
</soap:Body>
</soap:Envelope>


Response :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:ns1="uri://sites.meucarronovo.com.br/web_services/registra_veiculo/serverV2.php"; 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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">;
<SOAP-ENV:Body>
<ns1:consultaModelosByMarcaResponse>
<return xsi:type="SOAP-ENC:Struct">
<ret_code xsi:type="xsd:string">200</ret_code>
<ret_message xsi:type="xsd:string">350|AUTOMÓVEL,350 Z|AUTOMÓVEL,3.7|AUTOMÓVEL,370|AUTOMÓVEL,ALTIMA|AUTOMÓVEL,ARMADA|UTILITÁRIO,ARMADA|AUTOMÓVEL,AX|UTILITÁRIO,D-21|UTILITÁRIO,FRONTIER|UTILITÁRIO,GRAND|AUTOMÓVEL,GT-R|UTILITÁRIO,GT-R|AUTOMÓVEL,INFINIT|AUTOMÓVEL,INFINIT|UTILITÁRIO,JUKE|UTILITÁRIO,KING-CAB|UTILITÁRIO,LIVINA|AUTOMÓVEL,MARCH|AUTOMÓVEL,MAXIMA|AUTOMÓVEL,MICRA|AUTOMÓVEL,MURANO|AUTOMÓVEL,MURANO|UTILITÁRIO,NX|AUTOMÓVEL,NX 2000|AUTOMÓVEL,PATHFINDER|AUTOMÓVEL,PATHFINDER|UTILITÁRIO,PICK-UP|UTILITÁRIO,PRIMERA|AUTOMÓVEL,QUEST|AUTOMÓVEL,SENTRA|AUTOMÓVEL,SX|AUTOMÓVEL,SX 240|AUTOMÓVEL,TERRANO|UTILITÁRIO,TIIDA|AUTOMÓVEL,VERSA|AUTOMÓVEL,X TERRA|UTILITÁRIO,X-TERRA|UTILITÁRIO,X TRAIL|UTILITÁRIO,X-TRAIL|UTILITÁRIO,ZX|AUTOMÓVEL,ZX 300|AUTOMÓVEL</ret_message>
</return>
</ns1:consultaModelosByMarcaResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Have any idea whats wrong, Header ... ??
Thank yours
Mario Gomes

 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic