Bonjour à tous,

j'ai un problème pour envoyer un message SOAP à un service distant :

Voici mon code :

FileInputStream file = new FileInputStream("/home/youssef/workspace/Test/xml/Gen_Traceroute_SOAP.xml");
SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
SOAPConnection con = factory.createConnection();
MessageFactory messageFactory = MessageFactory.newInstance();
System.out.println("Connnexion OK...");
SOAPMessage message = messageFactory.createMessage();
//Create objects for the message parts
SOAPPart sp = message.getSOAPPart();
System.out.println("Create message OK...");

StreamSource ss_msg = new StreamSource(file);
sp.setContent(ss_msg);

message.saveChanges();

System.out.println("Content added...");
message.writeTo(System.out);
System.out.println("****-_-****-_-****-_-****-_-****-_-****");

//Send the message and get a reply

//Set the destination
String url = "http://---.--.---.---:----/services/MP/GENERIC/";
//Send the message
try{
SOAPMessage reply = con.call(message,url);
System.out.println("The message is sent...");
System.out.println("\nRESPONSE:\n");
//Create the transformer
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();

//Extract the content of the reply
Source sourceContent = reply.getSOAPPart().getContent();

//Set the output for the transformation
StreamResult result = new StreamResult(System.out);
transformer.transform(sourceContent, result);
System.out.println();

//Close the connection
con.close();
}
catch(Exception e){e.getMessage();}

}

Voici la réponse :

Connnexion OK...
Create message OK...
Content added...
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<nmwg:message xmlns:nmtm="http://ggf.org/ns/nmwg/time/2.0/"
xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/"
xmlns:nmwgt="http://ggf.org/ns/nmwg/topology/2.0/"
xmlns:select="http://ggf.org/ns/nmwg/ops/select/2.0/"
xmlns:generic="http://ggf.org/ns/nmwg/tools/generic/2.0/"
type="SetupDataRequest">
<nmwg:metadata id="status_meta">
<generic:subject id="status_subject">
<nmwgt:endPointPair/>
</generic:subject>
<generic:parameters id="gen-params">
<nmwg:parameter name="command" value="traceroute"/>
<nmwg:parameter name="commandline" value="---.--.---.---"/>
</generic:parameters>
<nmwg:eventType>http://ggf.org/ns/nmwg/tools/generic/2.0/</nmwg:eventType>
</nmwg:metadata>
<nmwg:data id="data1" metadataIdRef="status_meta"/>
</nmwg:message>
</soapenv:Body>
</soapenv:Envelope>

****-_-****-_-****-_-****-_-****-_-****
Jul 8, 2010 12:27:24 PM com.sun.xml.internal.messaging.saaj.soap.MessageFactoryImpl createMessage
SEVERE: SAAJ0531: Unable to parse content type



Quelqu'un peut-il m'aider s'il vous plaît ?