QName serviceName = new QName(targetNS, "DocBareService");
QName portName = new QName(targetNS, "DocBarePort");
URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-samples-soapbinding/DocBareService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
Dispatch dispatch = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
String reqEnv =
"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
" <env:Header/>" +
" <env:Body>" +
" <ns1:SubmitPO xmlns:ns1='" + targetNS + "'>" +
" <ns1:product>Ferrari</ns1:product>" +
" </ns1:SubmitPO>" +
" </env:Body>" +
"</env:Envelope>";
SOAPMessage reqMsg = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));
SOAPMessage resMsg = (SOAPMessage)dispatch.invoke(reqMsg);
QName qname = new QName(targetNS, "SubmitPOResponse");
SOAPElement soapElement = (SOAPElement)resMsg.getSOAPBody().getChildElements(qname).next();
soapElement = (SOAPElement)soapElement.getChildElements(new QName(targetNS, "product")).next();
assertEquals("Ferrari", soapElement.getValue());