On Wed June 24 2009 1:09:21 pm John Baker wrote:
> Dan,
>
> Do you have any thoughts on how to replace the Axis code:
>
> Service service = new Service();
> Call call = (Call)service.createCall();
> call.setTargetEndpointAddress(new URL(endPoint));
> call.setOperationName(new QName("http://www.xyz.com", method) );
> if (username != null) call.setUsername(username);
> if (password != null) call.setPassword(password);
> String ret = (String)call.invoke(new Object[] { message });
>
> I get a NullPointerException when I execute it, coming from:
>
> at
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.checkServiceCla
>ssAnnotations(ReflectionServiceFactoryBean.java:2156)
>
> Apparently because I'm not setting a service class. However I don't have a
> service class - this is an anonymous call.
I don't really think there is a way. With JAX-WS (and CXF), you either need
to:
1) Provide a description for how to format the soap body, usually through a
wsdl.
or
2) Handle the entire contents of the soap body yourself (via Dispatch in
PAYLOAD mode). That would require you to create a DOM (or streamsource) or
similar to format the payload.
The authorization stuff is simple. The JAX-WS spec covers that via the
BindingProvider request context. The rest of the code above is not really
migrateable easily.
Dan
>
> Thanks,
>
>
> John
>
> On Monday 22 June 2009 20:03:46 you wrote:
> > I don't think it's QUITE as simple with JAX-WS. The code would look
> > similar to:
> >
> > Service service = Service.create(serviceName);
> > service.addPort(portName, "http://schemas.xmlsoap.org/soap/",
> >
> > "http://localhost:9006/SOAPDispatchService/SoapDispatchPort");
> > (serviceName and portName could be fairly random QNames)
> > Dispatch<DOMSource> disp = service.createDispatch(portName,
> > DOMSource.class, Service.Mode.PAYLOAD);
> > (You can use DOMSource, StreamSource, SAXSource)
> >
> >
> > DOMSource domResMsg = disp.invoke(domReqMsg);
> >
> >
> >
> > Dan
> >
> > On Sun June 21 2009 9:35:17 am John Baker wrote:
> > > Hi,
> > >
> > > Thanks for your response. I've written an interceptor to do it, but
> > > was just looking at the Dispatch API. I've got some old Axis code that
> > > I'm replacing - it does this:
> > >
> > > Service service = new Service();
> > > Call call = (Call)service.createCall();
> > > call.setTargetEndpointAddress(new URL(endPoint));
> > > call.setOperationName(new QName("http://www.xyz.com", method)
> > > ); if (username != null) call.setUsername(username);
> > > if (password != null) call.setPassword(password);
> > > String ret = (String)call.invoke(new Object[] { message });
> > >
> > > Is that easy to replace with the jaxws (dispatch?) api? It did nothing
> > > more than call a WS method, passing one parameter and assuming a String
> > > response. No WSDL involved...
> > >
> > >
> > > John
> > >
> > > P.S. If anyone needs the interceptor then I'm happy to post it.
> > >
> > > On Sunday 21 June 2009 13:19:37 you wrote:
> > > > John Baker wrote:
> > > > > Hello,
> > > > >
> > > > > How does one obtain the raw SOAP message returned from a client
> > > > > webservice call? Ideally, as String or a Document would be nice.
> > > > >
> > > > >
> > > > > John
> > > >
> > > > You can achieve the same in either of two ways:
> > > >
> > > > A. You can use Dispatch API [1] to write your client where you can
> > > > get either Message (Body element) or Payload (entire SOAP Envelope).
> > > > or
> > > > B. You can write and plugin your own interceptor [2] in the
> > > > interceptor chain where you can get the hold of soap message.
> > > >
> > > > With Regards,
> > > > Mayank
> > > >
> > > > [1]. http://cwiki.apache.org/CXF20DOC/jax-ws-dispatch-api.html
> > > > [2]. http://cwiki.apache.org/CXF20DOC/interceptors.html
--
Daniel Kulp
[email protected]
http://www.dankulp.com/blog