I'l think about it. One of the possibilities is to do it similar to Spring-MVC's new @Controller and @RequestMapping style. Basically, you would be able to define a WebServiceMessage or MethodContext parameter, and it will be injected by Spring-WS.
I'l think about it. One of the possibilities is to do it similar to Spring-MVC's new @Controller and @RequestMapping style. Basically, you would be able to define a WebServiceMessage or MethodContext parameter, and it will be injected by Spring-WS.
I am trying to solve the same problem mentioned in this thread. From what I have understood so far, if i need to view the SOAP header I would have to define a custom interceptor which would read the message context. This context can then be set into the end point.
My question is how do i set a variable in the endpoint from the interceptor. Is it something I would do using the spring configuration files or do I have to programatically do it.
Any help on this would be appreciated.
Irfan
Hi Arjen,
Did you happen to create a JIRA for this issue?
I think is a common problem - Passing Data from the interceptor to the endpoint and the other way round without loosing the flexibility to use @Endpoint or any other DOM/Marshalling based endpoint.
Implementing MessageEndpoint which handles messages individually can lead to a inflated code base for large projects.
Using the threadlocal approach is something i can live with but would prefer if the Spring Wiz Team did us a favor :)
Thanks
Why not simply inject a "request" scoped bean in an Interceptor and in the Endpoint?
The interceptor will extract the infos from the SOAP Header and put them in the bean and then the Endpoint will be able to read them.
If you are using a custom Soap Header you can also unmarshal it in the Interceptor to a java Object.
How does injecting a request scoped bean into the interceptor and the endpoint work, with regards to this article: http://static.springframework.org/sp...ot-interaction
Did I read this wrong or is this saying that you won't necessarily get a new instance of the request scoped bean?
As stated in the Spring Reference guide you mention:
"the Spring container will create a brand new instance of the.... bean using the '...' bean definition for each and every HTTP request".
Where did you read about a different behaviour?
You have only to pay attention to not reassign the variable, referring to the bean, in your code but only change its internal state to pass information from interceptor to endpoint.
Never mind I must have been reading the wrong section.
Thanks Lucian.
No I didn't do that yet, so please go ahead and do it :).
Injecting various objects as method parameters (such as MessageContext, and maybe others), is a major feature, and therefore not something I can do in the 1.5 timeline though. It will be something for the next major release.
I can't understand why open a JIRA issue for something that can be already done as required by Rahul Mishra.
I explain how:
1)I define a request scoped bean both in the interceptor and in the endpoint that can be also an AbstractMarshallingPayloadEndpoint with automatic marshalling/unmarshalling of SOAP body
2)In the interceptor I read the SOAP Header and can Unmarshal it to a object using Jibx , JAXB or what I want es:
3)In the endpoint in the variable referring to the request scoped bean I have the info of the SOAP header.Code:public boolean handleRequest(MessageContext messageContext, Object endpoint)
throws Exception {
System.out.println("Interceptor invocato ");
AxiomSoapMessage axiomMsg = (AxiomSoapMessage)messageContext.getRequest();
SOAPEnvelope axiomEnvelope = axiomMsg.getAxiomMessage().getSOAPEnvelope();
SOAPHeader header=axiomEnvelope.getHeader();
QName elementQName = new QName( "http://www.openspcoop.org/integrazione","integrazione");
OMElement element=null;
if (header!=null)
element=header.getFirstChildWithName(elementQName);
if (element!=null)
{
IUnmarshallingContext ctx = BindingDirectory.getFactory(IntegrazioneImpl.class).createUnmarshallingContext();
Integrazione appo = (Integrazione) ctx.unmarshalDocument(new StringReader(element.toString()));
//integra is my request scoped bean
integra.setInte(appo);
}
return true;
}
With client interceptor this works also for Web Services clients If I need.
Hi luciano61,
I am not sure how to unmarshall soap header elements can you explain it a bit. I a, trying to get a particular soap header element named session. after that i want to unmarshall it using jaxb. but not exaxtly sure how to do it. Here what my interceptor code looks like
}Code:public boolean handleRequest(MessageContext messageContext, Object endpoint)
throws Exception {
System.out.println("Intercepted");
SoapHeader soapHeader = ((SaajSoapMessage) messageContext.getRequest()).getEnvelope().getHeader();
Iterator i = soapHeader.examineAllHeaderElements();
SessionHeader sessionHeader = null
for (Iterator iterator = soapHeader.examineAllHeaderElements(); iterator.hasNext();) {
SoapHeaderElement headerElement = (SoapHeaderElement) iterator.next();
if(headerElement.getName().getLocalPart().equals("session")){
// i want to unmarshall this element into Session Header.
}}
Secondly can you please provide configuration settings for the code provided in ur last post especially for the request scope bean and its injection in other beans.
thanks,
Muein