cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse Pangburn <Jesse.Pangb...@us.lawson.com>
Subject RE: dispatch api with ws-addressing
Date Wed, 17 Aug 2011 18:17:16 GMT
Hi Dan,
Thanks for the suggestion, I'm trying to figure out one of those cases.  I changed the code
to this to try a DOMSource instead:
	Dispatch<Source> disp = service.createDispatch(new QName("urn:ihe:iti:xds-b:2007",
"DocumentRegistry_Port_Soap12"), Source.class, Service.Mode.PAYLOAD, new AddressingFeature());
	InputStream is = IBServer.class.getResourceAsStream("RegistryQuery.xml");
	Document doc = XMLUtils.parse(is);
	DOMSource reqMsg = new DOMSource(doc);
	Source response = disp.invoke(reqMsg);

DOMSource also sent the same wrong action header.  I see that I get back a StaxSource (CXF
StaxSource, not javax StAXSource) in this case so I tried using that as the input next:
	Dispatch<Source> disp = service.createDispatch(new QName("urn:ihe:iti:xds-b:2007",
"DocumentRegistry_Port_Soap12"), Source.class, Service.Mode.PAYLOAD, new AddressingFeature());
	InputStream is = IBServer.class.getResourceAsStream("RegistryQuery.xml");
	XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory();
	XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(is, "UTF-8");
	StaxSource staxSource = new StaxSource(xmlStreamReader);
	Source response = disp.invoke(staxSource);

StaxSource also sent the same wrong action header.  I also tried SAXSource:
	InputSource inputSource = new InputSource(is);
	SAXSource saxSource = new SAXSource(inputSource);
	Source response = disp.invoke(saxSource);

And lastly I tried javax's StAXSource:
	//StaxSource staxSource = new StaxSource(xmlStreamReader);
	StAXSource staxSource = new StAXSource(xmlStreamReader);
	Source response = disp.invoke(staxSource);

I thought maybe one of these was one of the cases you referred to, but assume I misunderstood
or am doing something else wrong.  Or maybe this only works in soap 1.1 wsdls or something?

Thanks,
Jesse

-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: Wednesday, August 17, 2011 10:29 AM
To: users@cxf.apache.org
Cc: Jesse Pangburn
Subject: Re: dispatch api with ws-addressing

On Wednesday, August 17, 2011 12:15:53 PM Jesse Pangburn wrote:
> Hi,
> Thanks for the suggestion, that will work.  I was hoping there was some way
> for CXF to do it automatically from the WSDL and the message body, but this
> manual step is at least simple and makes sense.

In SOME cases it can, but I'm not sure if StreamSource is one of them.

Another option is:

disp.getRequestContext().put(MessageContext.WSDL_OPERATION,
    new QName(ns, "myOperation")

which will tell CXF what operation that dispatch is mapped to.

One note:  you may want to switch from StreamSource to just "Source" if 
possible.  StreamSource is really the worse of the possible source types from 
a performance standpoint.   On the incoming side, we pretty much suck the 
message into a byte[] or file and re-wrapper that with a new parser.   Kind of 
crappy.   If you do Provider<Source>, you would likely get a subclass of 
SAXSource which would allow us to maintain some level of streaming.  

Dan



> 
> Thank you,
> Jesse
> 
> -----Original Message-----
> From: Aki Yoshida [mailto:elakito@googlemail.com]
> Sent: Wednesday, August 17, 2011 2:09 AM
> To: users@cxf.apache.org
> Subject: Re: dispatch api with ws-addressing
> 
> Hi,
> you need to set the soap action in the dispatch client's request context.
> In your case, you need to add the following line:
> 
> disp.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY,
> "urn:ihe:iti:2007:RegistryStoredQuery") ;
> 
> Regards, aki
> 
> 2011/8/17 Jesse Pangburn <Jesse.Pangburn@us.lawson.com>:
> > Hi,
> > I'm trying to use the dispatch API and while I can make the service call
> > ok, the ws-address "action" header is wrong.  Here's my code: URL
> > wsdlURL = new
> > URL("file:/home/jpangburn/Desktop/IHE/XDSb.Support.Materials.v9/wsdl/XD
> > S.b_DocumentRegistry.wsdl"); Service service = Service.create(wsdlURL,
> > new QName("urn:ihe:iti:xds-b:2007", "DocumentRegistry_Service"));
> > Dispatch<StreamSource> disp = service.createDispatch(new
> > QName("urn:ihe:iti:xds-b:2007", "DocumentRegistry_Port_Soap12"),
> > StreamSource.class, Service.Mode.PAYLOAD, new AddressingFeature());
> > InputStream is =
> > IBServer.class.getResourceAsStream("RegistryQuery.xml"); StreamSource
> > request = new StreamSource(is);
> >          StreamSource response = disp.invoke(request);
> > 
> > Basically, I try to create a service from a WSDL with the service QName,
> > then create a Dispatch from the port's QName while passing "new
> > AddressingFeature()" to turn on WS-Addressing.  The action header comes
> > out like this: <Action
> > xmlns="http://www.w3.org/2005/08/addressing">http://cxf.apache.org/jaxw
> > s/dispatch/DocumentRegistry_PortType/InvokeRequest</Action>
> > 
> > This is wrong because the SOAP12 binding's operation has the following:
> > <soap12:operation soapAction="urn:ihe:iti:2007:RegistryStoredQuery"/>
> > 
> > So the header should be:
> > <Action
> > xmlns="http://www.w3.org/2005/08/addressing">urn:ihe:iti:2007:RegistryS
> > toredQuery</Action>
> > 
> > All I can guess is that the Dispatch API doesn't know which operation
> > I'm calling so it makes up this generic action header for the port
> > instead of looking at the message I'm sending, determining the
> > operation called, and grabbing the correct soap action to use in the
> > action header.  Am I doing something wrong or is this a limitation in
> > the Dispatch API's support for WS-Addressing?
> > 
> > Thanks,
> > Jesse
-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com



Mime
View raw message