Java Reference
In-Depth Information
private static final String NS =
"http://www.webserviceX.NET/";
public static void main(String...arg) {
new AddSoapAction().invoke();
System.out.println("\nAll done.");
}
public AddSoapAction() { }
private void invoke(){
try {
//Prepare service to call
Service service = createService();
QName portQName = new QName(NS, "StockQuoteSoap");
Dispatch<SOAPMessage> dispatch =
service.createDispatch(portQName,
SOAPMessage.class, Service.Mode.MESSAGE);
//Add SOAPAction
dispatch.getRequestContext().put(
Dispatch.SOAPACTION_USE_PROPERTY, "1");
dispatch.getRequestContext().put(
Dispatch.SOAPACTION_URI_PROPERTY,
"http://www.webserviceX.NET/GetQuote");
//Prepare request
SOAPMessage request = createMessage();
//send request and get response
SOAPMessage response = dispatch.invoke(request);
//Write response to console
System.out.println("\nGot Response:\n");
response.writeTo(System.out);
System.out.println("\n");
} catch (Exception ex) {
ex.printStackTrace();
}
}
private SOAPMessage createMessage() throws SOAPException {
//Create a SOAPMessage
Search WWH ::




Custom Search