I have CXF Interceptor that checks field in SOAP header. I want to skip this check for a single method.
Is it possible to do it without parsing soap and checking for method name (for example, annotation).
Thank you!
If you put your interceptor fairly late in the chain (USER_LOGICAL for example), you can grab the BindingOperationInfo object from the exchange to determine which operation was used to process the body. From there, decide wether to look at the SOAP headers or not.
An interceptor gets executed even before CXF has started parsing the xml message (actually I use them to change the xml parser secure factory implementation class :P ), so I think what you need is not supported by the architecture (or at least I am unable to find it, if someone wants to bring some light here I will thank it too).
http://cxf.apache.org/docs/interceptors.html
May you separe your functionality in 2 webservices, each one with different interceptors and validation levels?
Related
Is there a way to intercept and record every JSON message exchanged between a Eclipse RAP-Client and a RAP-Server?
The best way to do this is a servlet filter. See this answer for an example how to read the response in a filter.
As an alternative, you could register a PhaseListener and try to hook into RWT's internal APIs such as ClientMessage and ProtocolMessageWriter. However, these internals are subject to change and even the PhaseListener interface will be deprecated and likely removed in RAP 3. Therefore, I wouldn't recommend this approach.
I am working on REST API with CXF framework. Anybody can explain to me more detail about what's different between InFaultInterceptor vs. OutFaultInterceptor? They seems belong to different phase of interceptor. But Do we should put what logic into different Fault Interceptor? I need to abort interceptor chain and response custom response message. I cannot see different on InFaultInterceptor and OutFaultInterceptor for my scenario. What's your typical error handler interceptor? Could you brief introduce your error handling structure of CXF if convenient?
The concept in the interceptor chain is pretty straightforward, in is coming in, out is going out.
For instance, if you want to change the way faults are populated in a SOAP Fault, say to get some variable you are putting in the exception you are throwing, you would use say the Soap12FaultOutInterceptor to modify the fault you are generating. The Soap12FaultInInterceptor would be used to handle incoming faults.
My real question is why do you want to use the interceptor chain, and what is your use case? This is not unusual, but many times unnecessary especially with Spring and aspecting, IMO.
I'm trying to write my first client using Spring-WS and am getting a little confused at some basics. I need to insert a SAML token into the header, and I've noticed that the WebServiceTemplate class allows for both Interceptors and WebServiceMessageCallbacks.
Can someone please help me understand why I should use one versus another?
Secondly, I noticed that the WST class allows for a list of interceptors, but only a single callback. Does anyone know what the logic was behind that design decision? Why is there no ability to pass an array or list of Callbacks?
Thanks,
Eric
I was wondering the same after reading your question (-:
On this link there's a brief explanation and that's exactly how I use both. For instance, for a specific request I need to set the SOAP action:
JAXBElement<Response> response = (JAXBElement<Response>) webserviceTemplate.marshalSendAndReceive(
request,
new SoapActionCallback("PutOrganisationUnitRequest")
);
This is indeed a simple, anonymous class as mentioned in the link. An interceptor on the other hand is defined and used for all requests. Take a look at XwsSecurityInterceptor for instance, I use that to set the authentication on ALL requests.
This may have already been answered and I just can't find it so feel free to point if needed.
I have a JAVA WSDL endpoint that I can successfully use to generate a reference. I have also used the WSDL sent from the programmers of this end point and again was successful in creating class files to use.
However when I create the objects needed to feed this service, in both cases, I receive an error that he cannot use the payload that I am sending.
Looking at it using the SoapUI tool it seems that his service is expecting some more information in the payload tags that does not seem to make into my classes.
Example: I can create <Tag1></Tag1> but he needs <init:Tag1></init:Tag1>
I don't know where the "init" prefix is getting dropped.
I am using VS 2010 and generating a simple web reference. Any tips would be helpful at this point.
The way I approach these problems is this:
use a same-technology client to connect to the service.
Trace the message on the wire. If ncessary strip out signatures and encryption so that you can get a readable XML message.
now, use the different-technology client (in this case .NET) to build client-side stubs and connect to the service. Trace the message on the wire.
Compare the two, and tweak the different-technology client to get it to match.
I use Fiddler2 to captures the traces of the HTTP messages. If you are not using HTTP then you will need something else.
Keep in mind, what you want is not string equality, but equivalence in the XML infoset.
An element like <init:Tx> may be equivalent to <Tx>, if the default namespace in the latter case matches the init namespace in the former. If you don't quite get what this means, then you need to read up on xml namespaces and get comfortable with the concepts.
In many many cases, I've found that it's XML namespace disagreement issues that cause the lack of interoperability. In one case I found that a missing slash on a namespace (http://foo/bar rather than http://foo/bar/) was enough to cause communication to fail. Figuring out what to tweak in order to get the actual message to match the requirement message is somewhat of a black art - I don't know how to explain it.
in some cases I resort to doctoring the WSDL document to get the different-technology client to do what I want.
good luck.
Yes I have since figured out that using the 4.0 svcutil.exe is the best thing in the world for seeing these issues. Again as I stated in a comment above, I figured out that it was merely a namespace issue and it wasn't .Net that was having the issue but the Java on the other end.
Hopfully this will make it easier to see usinf the specific 4.0 generator...
"%PROGRAMFILES%\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\svcutil.exe" /async http://SomeExternalWeb/ExtService.svc?wsdl /ct:System.Collections.Generic.List`1 /n:*,MyNS.Messaging.Services
I love the class generation over the reference generation any day.
I am facing some problem while returning data from web services.
I am using Metro stack.
Problem:
The problem is my data contain some control characters. I don't want to encrypt my data, as this will involve client side code changes as well.
Better way is to remove control characters, but character by characters scanning and removing/replaceAll will have some performance impact.
Probable solution:
What I want to do is intercept SOAP message before metro send it to client and check control characters. And then replace all control characters of XML before returning.
Do anyone here have any idea how can I intercept response before returning? Or
how I can write my own serializer/deserializer where I can replace control char?
Thanks.
I suppose you could use the Provider interface to do this. Your implementation of the provider would be called instead of the actual web service. Then you would parse the XML and forward the call to you service implementation.
I find it somewhat cumbersome to work with, but if it works..
I found XMLAdapter very useful in my case.
Adding info as in case any buddy can find it useful.
Reference: http://weblogs.java.net/blog/kohsuke/archive/2005/09/using_jaxb_20s.html
XMLAdapter contain abstract method marshal and unmarshal. So I used appropriate encoder in marshal/unmarshal method.