Estou seguindo o seguinte código que peguei em outro post e to testando,
mas to obtendo o seguinte erro :
06/03/2013 17:04:56 com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
GRAVE: SAAJ0008: Bad Response; Unsupported Media Type
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (415Unsupported Media Type
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
at br.com.soap.ClientFactory.call(ClientFactory.java:34)
at br.com.soap.ClientFactory.main(ClientFactory.java:114)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (415Unsupported Media Type
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
public static void call(String envelope , String urlAddress) throws SOAPException{
MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage message;
try {
MimeHeaders header = new MimeHeaders();
header.addHeader("content-type", "application/soap+xml; charset=utf-8");
//header.addHeader("content-Lenght", "250");
message = factory.createMessage(header, new ByteArrayInputStream(envelope.getBytes()));
SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
URL url = new URL(urlAddress);
System.out.println("Message enviada \n"+message.getContentDescription());
SOAPMessage res = con.call(message, url);
System.out.println("bla");
ByteArrayOutputStream in = new ByteArrayOutputStream();
message.writeTo(in);
System.out.println("in :\n"+in.toString());
ByteArrayOutputStream out = new ByteArrayOutputStream();
res.writeTo(out);
} catch (Exception e) {
e.printStackTrace();
}
}
Alguem tem alguma idéia?