1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| QName serviceName = new QName(portName_, service_);
QName portName = new QName(portName_, service_+"Port");
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
/** Create a Dispatch instance from a service.**/
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName,
SOAPMessage.class, Service.Mode.MESSAGE);
/** Create SOAPMessage request. **/
// compose a request message
MessageFactory mf;
mf = MessageFactory.newInstance();
// Create a message. This example works with the SOAPPART.
SOAPMessage request = mf.createMessage();
SOAPPart part = request.getSOAPPart();
// Obtain the SOAPEnvelope and header and body elements.
//
SOAPEnvelope env = part.getEnvelope();
//
SOAPHeader header = env.getHeader();
//env.setAttribute("xmlns:cal", "http://calcul/");
SOAPBody body = env.getBody();
//
QName ns = new QName(portName_, action_, cutPortName_);
SOAPBodyElement el = body.addBodyElement(ns);
SOAPElement message;
//
for(int i=0;i<Action_param.length;i++){
message = el.addChildElement(Action_param[i][0]);
message.addTextNode(Action_param[i][1]);
}
request.saveChanges();
//
// /** Invoke the service endpoint. **/
//
SOAPMessage response = dispatch.invoke(request);
idrequest = response.getSOAPPart().getEnvelope().getBody().getFirstChild().getTextContent();
return idrequest; |
Partager