boa noite.
estou tentando fazer um envio de um XML a um web service, e estou tendo problemas com o msm
acredito q seja com a conexão com o web service ou com o envio do xml, não consegui identificar qual dos 2 :oops:
aqui onde estou fazendo esse web service se usa o cxf e axis e estão querendo fazer uma forma genérica q sirva para ambos, so que eu não sou muito experiente com web services (na verdade fiz muito pouco :oops: )
public static void main(String[] args) throws Exception {
String strURL = "http://localhost:8080/xxxx/serv/Emiss";
String strXMLFilename = "C:\\Users\\xxxx\\Documents\\yyyyy.txt";
File input = new File(strXMLFilename);
BufferedReader br = new BufferedReader(new FileReader(strXMLFilename));
PostMethod post = new PostMethod(strURL);
FileInputStream arq = new FileInputStream(input);
post.setRequestEntity(new InputStreamRequestEntity(new FileInputStream(input), input.length()) );
post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");
HttpClient httpclient = new HttpClient();
try {
int result = httpclient.executeMethod(post);
System.out.println("Response status code: " + result);
System.out.println("Response body: ");
System.out.println(post.getResponseBodyAsString());
} finally {
post.releaseConnection();
}
este é o xml q estou enviando
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:core="http://xxx.yyy.com.br/">
<soapenv:Header/>
<soapenv:Body>
<core:executa>
<requisicao>
<cpfCnpj>xxxxxxxxxxx</cpfCnpj>
</requisicao>
</core:executa>
</soapenv:Body>
</soapenv:Envelope>
idependente de mexer no arquivo xml ou no na url sempre volta isso:
(exceto se eu deixar algum deles “” || null )
<?xml version="1.0" encoding="ISO-8859-1"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode>
<faultstring>no SOAPAction header!</faultstring>
<detail>
<ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">yyyy_6445</ns2:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
testando o web service no soupui ele funciona direitinho passando o mesmo parâmetro.
alguém poderia me dar uma ajudinha neste problema?