Is there a way to retrieve the targetNamespace from the message, its QNames
(from Version of the message)?

For example if I have something like this on the service classt:


@WebService(portName = "TestService",

serviceName = "TestServiceService",

*targetNamespace = **"http://example.test.com/services/v01"**, *

endpointInterface = "com.test.services.v01.TestService"

)
Is the specific 'targetNamespace' retrievable from anywhere of the
SoapMessage or its attributes?

I've tried the namespaceURI from:

1. message.getVersion().getEnvelope().getNameSpaceURI() but that gives me "
http://schemas.xmlsoap.org/soap/envelope/";
 2. message.getVersion().getNamespace() but that gives me "
http://schemas.xmlsoap.org/soap/envelope/";

Seems like since I am creating the Header on the fly without binding it, the
targetNamespace is not the one of the service. Maybe I am totally off here.


On Fri, Oct 30, 2009 at 10:59 AM, Arik Gorelik <arikg...@gmail.com> wrote:

> I figured out how to change the element name, it is just the 'localPart'
> attribute of the QName. Still struggling on how to get the correct
> targetNamespace (for the service endpoint) instead of the default one
> xmlns="http://schemas.xmlsoap.org/soap/envelope/
>
>
> On Fri, Oct 30, 2009 at 10:31 AM, Arik Gorelik <arikg...@gmail.com> wrote:
>
>> That's awesome! I am able to get the value back in the header response.
>> Just need to figure out how to set the name of the element (default is
>> 'Header').
>>
>> Still, the header part seems kind of tricky to me. Perhaps the
>> @WebParam(header=true) way is much simpler, but unfortunately I cannot use
>> that.
>>
>>   On Fri, Oct 30, 2009 at 9:36 AM, Daniel Kulp <dk...@apache.org> wrote:
>>
>>>
>>> If it's something as simple as just a String, it's probably easier to
>>> just use
>>> a DOM and don't bother with the Databinding stuff.   Using some CXF
>>> utils:
>>>
>>> Document doc = XMLUtils.newDocument();
>>> Element el  = XMLUtils.createElementNS(doc, qname);
>>> el.appendChild(XMLUtils.createTextNode(doc, "12345-67890");
>>>
>>> new Header(qname, el)
>>>
>>> If there isn't a databinding, it assumes a DOM.
>>>
>>> Dan
>>>
>>>
>>>
>>> On Fri October 30 2009 12:08:27 pm Arik Gorelik wrote:
>>> > Great. Thank you for the pointers. I am able to get the 'SoapMessage'
>>> > reference and call getHeaders, get the List, etc, etc. My interceptor
>>> is in
>>> > the PRE_STREAM phase and I am also experimenting in the MARSHAL phase
>>> as
>>> > well.
>>> >
>>> > However, I cannot seem to figure out how to bind my string literal "id"
>>> to
>>> > the actual header element. Is there a utility or an easy way to create
>>> a
>>> > 'Header' instance? I am using the constructor, but not 100% sure what I
>>> >  need to pass for the DataBinding. Here is my code:
>>> >
>>> > QName qname = new QName(message.getVersion().getHeader());
>>> > Object obj = "12345-67890";
>>> > DataBinding db = ?; // where can I get this?
>>> >
>>> > message.getHeaders().add(*new* Header(qname, obj, db));
>>> >
>>> > I really appreciate your help.
>>> > Arik.
>>> >
>>> > On Fri, Oct 30, 2009 at 7:06 AM, Daniel Kulp <dk...@apache.org> wrote:
>>> > > On Thu October 29 2009 9:07:16 pm Arik Gorelik wrote:
>>> > > > Basically, I am wondering if it is possible to set something in the
>>> > > > soap response header in the interceptor (not in the service method
>>> > > > implementation) during PRE_STREAM phase.
>>> > >
>>> > > Well, yea, but in an interceptor you have two options:
>>> > >
>>> > > 1) Exactly the same way as in (4).
>>> > > message.get(Header.HEADER_LIST)
>>> > > returns the List<Header> (or null in which case you create a
>>> List<Header>
>>> > > and
>>> > > add it)
>>> > >
>>> > > 2) If you interceptor is Interceptor<SoapMessage> or if you cast the
>>> > > passed in
>>> > > Message to a SoapMessage, there is a getHeaders() call on
>>> soapmessage.
>>> > >
>>> > >
>>> > > Dan
>>> > >
>>> > > > On Thu, Oct 29, 2009 at 2:09 PM, Arik Gorelik <arikg...@gmail.com>
>>> > >
>>> > > wrote:
>>> > > > > Seems like if there is a heavy dependency on CXF in the project
>>> (as
>>> > > > > in
>>> > >
>>> > > my
>>> > >
>>> > > > > case), the best option is this one:
>>> > > > >
>>> > > > > 4. CXF proprietary way: In the context
>>> > > > > (BindingProvider.getRequestContext() on client, WebServiceContext
>>> on
>>> > > > > server), you can add a
>>> > > > > List<org.apache.cxf.headers.Header> with the key
>>> Header.HEADER_LIST.
>>> > >
>>> > > The
>>> > >
>>> > > > > headers in the list are streamed at the appropriate time to the
>>> wire
>>> > > > > according to the databinding object found in the Header object.
>>> Like
>>> > > > > option 1, this doesn't require changes to wsdl or method
>>> signatures.
>>> > > > > However, it's much faster as it doesn't break streaming and the
>>> > > > > memory overhead is less.
>>> > > > >
>>> > > > > Let's say I want to return an ID in the header with every
>>> response,
>>> > > > > is that something I can do in the PRE_STREAM interceptor on the
>>> OUT
>>> > > > > scope?
>>> > > > >
>>> > > > > Arik.
>>> > > > >
>>> > > > >   On Thu, Oct 29, 2009 at 10:48 AM, Daniel Kulp <
>>> dk...@apache.org>
>>> > >
>>> > > wrote:
>>> > > > >>  On Thu October 29 2009 1:01:20 pm Arik Gorelik wrote:
>>> > > > >> > Hello,
>>> > > > >> >
>>> > > > >> > I cannot seem to find any example of how to include/set
>>> > >
>>> > > headers/values
>>> > >
>>> > > > >> in
>>> > > > >>
>>> > > > >> > the SOAP response. Is there a CXF example on that? I can think
>>> of
>>> > >
>>> > > few
>>> > >
>>> > > > >> ways
>>> > > > >>
>>> > > > >> > to do this, but was wondering if anyone has a best practice
>>> > > > >> > sample.
>>> > > > >>
>>> > > > >> See the faq:
>>> > > > >>
>>> > > > >> http://cxf.apache.org/faq.html
>>> > > > >>
>>> > > > >>
>>> > > > >>
>>> > > > >> --
>>> > > > >> Daniel Kulp
>>> > > > >> dk...@apache.org
>>> > > > >> http://www.dankulp.com/blog
>>> > >
>>> > > --
>>> > >  Daniel Kulp
>>> > > dk...@apache.org
>>> > > http://www.dankulp.com/blog
>>> >
>>>
>>> --
>>>  Daniel Kulp
>>> dk...@apache.org
>>> http://www.dankulp.com/blog
>>>
>>
>>
>

Reply via email to