Looking for example code
acxsjones Aug 17, 2005 9:54 AMI am looking for example client code, standalone client code, that calls a soap services that requires the creation of a soap header.
Todate I have generated the stubs from the WSDL and been able to use the code below to access the service. But I am missing the steps of being able to either manually add the soap headers or to have a client handler do it for me. This is all from a java client outside any containers.
HelloWorld_Impl service = new HelloWorld_Impl();
HelloWorldEndpoint endPoint = service.getHelloWorldEndpointPort();
Stub stub = (Stub) endPoint;
stub._setProperty(Stub.USERNAME_PROPERTY, "scott");
stub._setProperty(Stub.PASSWORD_PROPERTY, "password");
stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:7070/helloworld/1.0");
try {
String output = endPoint.hello("Scott");
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
super.fail("exception caught in test case");
}
}
I tried added a client handler but nothing seams to execute it. I assume you have to be in a container for this methodology to work
HelloWorld_Impl service = new HelloWorld_Impl();
HelloWorldEndpoint endPoint = service.getHelloWorldEndpointPort();
Stub stub = (Stub) endPoint;
stub._setProperty(Stub.USERNAME_PROPERTY, "scott");
stub._setProperty(Stub.PASSWORD_PROPERTY, "password");
stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:7070/helloworld/1.0");
HandlerRegistry hr = service.getHandlerRegistry();
QName portName = new QName(MyFirstClientHandler.NAMESPACE_URI, MyFirstClientHandler.LOCAL_PART);
List handlerChain = hr.getHandlerChain(portName);
HandlerInfo hi = new HandlerInfo();
hi.setHandlerClass(MyFirstClientHandler.class);
handlerChain.add(hi);
try {
String output = endPoint.hello("Scott");
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
super.fail("exception caught in test case");
}
}