How to read Cookies in CXF Client
Does anybody know, how to read the JSESSIONID cookie? I'm sure, that the cookie is set by the server. I try this: this.service = JAXRSClientFactory.create("http://localhost";, RegistrationService.class); this.client = WebClient.client(this.service).accept(MediaType.APPLICATION_XML).type(MediaType.APPLICATION_XML); this.service.login(loginCredentials); // server call ClientConfiguration config = WebClient.getConfig(this.service); HTTPConduit conduit1 = config.getHttpConduit(); Map cookies = conduit1.getCookies(); //<- is empty String str = WebClient.getConfig(this.service).getHttpConduit().getClient().getCookie(); //<-is null What am i doing wrong? Any hints? Thanks!! -- View this message in context: http://cxf.547215.n5.nabble.com/How-to-read-Cookies-in-CXF-Client-tp3310363p3310363.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: How to read Cookies in CXF Client
Hi Sergey Yes, this helps. Thank you! Here is the code to extract the JSESSIONID value: // get all cookies List cookies = this.client.getResponse().getMetadata().get("Set-Cookie"); if (cookies != null && !cookies.isEmpty()) { String cookie; for (Object object : cookies) { cookie = (String) object; if (cookie.contains("JSESSIONID")) { // cookie looks like that: JSESSIONID=m4i8fbdufhiy12tlnpd1hfp3f;Path=/ cookie = cookie.substring(cookie.indexOf("=") + 1, cookie.indexOf(";")); } } } Cheers! Mike -- View this message in context: http://cxf.547215.n5.nabble.com/How-to-read-Cookies-in-CXF-Client-tp3310363p3313165.html Sent from the cxf-user mailing list archive at Nabble.com.
How to get @Path annotation value in cxf client
Hi, is it possible to get the value of a @Path annotation in the cxf client? What i have is: Webservice Interface: @Path("/RegistrationService") @Consumes( { "application/xml" }) @Produces( { "application/xml" }) public interface RegistrationService { @POST @Path("/user/register") public void register(RegistrationData registrationData); } Client-Side Implementation: public class RegistrationServiceImpl implements RegistrationService { private RegistrationService service; private Client client; public RegistrationServiceImpl() { // create proxy this.service = JAXRSClientFactory.create("http://localhost";, RegistrationService.class); // convert proxy to client (acts then like a browser) this.client = WebClient.client(this.service).accept(MediaType.APPLICATION_XML).type(MediaType.APPLICATION_XML); } @Override public void register(final RegistrationData registrationData) { String path = ??? // path should be "/user/register" registrationData.setMessageId(createMessageId(path, registrationData.getMail())); this.service.register(registrationData); } } does cxf offer a way to get that path value or do i have to get it with reflection? Thanks in advance mike -- View this message in context: http://cxf.547215.n5.nabble.com/How-to-get-Path-annotation-value-in-cxf-client-tp3326670p3326670.html Sent from the cxf-user mailing list archive at Nabble.com.
3.3.0 change log
Hi- Is there a change log for 3.3.0 I am not finding somewhere? We upgraded from 3.2.13 to 3.3.0 and it’s breaking our apps and I can’t figure out why. In one case we extend FailoverTargetSelector but it gets ignored. Thanks for any help- Mike Sent from ProtonMail Mobile
Fault thrown in Rest In-Interceptor not handled by ExceptionMapper
I have an ExceptionMapper which handles exceptions from my Rest service just fine. However when my "In" Interceptor throws a Fault, the ExceptionMapper does not handle it. Instead I get the standard (ugly) XML, e.g.: error message Is that the expected behavior? My server is set up like: And my interceptor looks like: public class MyInterceptor extends AbstractPhaseInterceptor { public FormatSettingInterceptor() { super(Phase.PRE_STREAM); } @Override public void handleMessage(Message message) throws Fault { throw new Fault("Not handled by ExceptionMapper!"); } } Any insight or help would be appreciated. Much thanks, Mike
Re: Fault thrown in Rest In-Interceptor not handled by ExceptionMapper
Thanks for your response. I gave this a shot and it seems to work pretty well, though is a lot more cumbersome, seeing as how we need to handle the marshalling directly. Unfortunately this also introduces a different place where an exception is not properly handled: when trying to find the target method in JAXRSUtils, if not found, a WebApplicationException is thrown but the custom fault out interceptor is not invoked. This results in an empty body in the HTTP response. Have you run into that? Thanks for your help, Mike On Thu, Dec 17, 2009 at 3:25 PM, vickatvuuch wrote: > > I have had a similar problem and worked it around by building a > CustomFaultOutInterceptor, > which handles everything that gets thrown for both REST and SOAP. Once you > have a single place to do it > you can translate Exception into HTTP response codes as well as you can > enchance > the default Soap fault as appropriate. > > > Mike O'Neil-2 wrote: >> >> I have an ExceptionMapper which handles exceptions from my Rest >> service just fine. However when my "In" Interceptor throws a Fault, >> the ExceptionMapper does not handle it. Instead I get the standard >> (ugly) XML, e.g.: >> >> error >> message >> >> Is that the expected behavior? My server is set up like: >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> And my interceptor looks like: >> >> public class MyInterceptor extends AbstractPhaseInterceptor { >> public FormatSettingInterceptor() { >> super(Phase.PRE_STREAM); >> } >> >> @Override >> public void handleMessage(Message message) throws Fault { >> throw new Fault("Not handled by ExceptionMapper!"); >> } >> } >> >> Any insight or help would be appreciated. >> >> Much thanks, >> Mike >> >> > > -- > View this message in context: > http://old.nabble.com/Fault-thrown-in-Rest-In-Interceptor-not-handled-by-ExceptionMapper-tp26833555p26834406.html > Sent from the cxf-user mailing list archive at Nabble.com. > >
Re: How do I access the request URI from an ExceptionMapper?
Sergey, Unless I am missing something, this solution is not thread safe. Is there a way to have ExceptionMapper instantiated as a prototype bean? Otherwise I don't see how this will work properly across more than 1 thread. But maybe I am wrong... looking forward to your clarification :) Thanks, Mike On Thu, Dec 17, 2009 at 4:31 PM, Henrik Martin wrote: > Thanks Sergey. That worked great. Cheers, > > /Henrik > > On Thu, 2009-12-17 at 09:33 +, Sergey Beryozkin wrote: >> Hi >> >> You can have a >> >> @Context >> private UriInfo uriInfo; >> >> or >> >> private UriInfo uriInfo; >> @Context >> public void setUriInfo(UriInfo uriInfo) {...} >> >> declared in your mapper class... >> cheers, Sergey >> >> - Original Message - >> From: "Henrik Martin" >> To: >> Sent: Thursday, December 17, 2009 12:14 AM >> Subject: How do I access the request URI from an ExceptionMapper? >> >> >> > Greetings. I have written a bunch of ExceptionMapper implementations to >> > catch a variety of business exceptions in our system and return them as >> > a special type of Response object. It works fine, but I need to get a >> > hold of the URI from the incoming request to set it in the outgoing >> > Response. Since the ExceptionMapper interface method toResponse() only >> > gives me the actual Exception that was thrown, is there another way I >> > can get the URI? Thanks, >> > >> > /Henrik >
Re: How do I access the request URI from an ExceptionMapper?
Great, thank you for the clarification. I don't see any limitation either. Mike On Thu, Dec 17, 2009 at 5:03 PM, Sergey Beryozkin wrote: > Hi > > It is thread safe, it is a thread-safe proxy which is injected. > > Now, as far as the lifecycle of providers is concerned (body > readers/writers, filters, exception mappers) : at the moment they are > always singletons (in CXF at least), hence thread safe proxies are > injected. > Resource classes can be prototypes though... > > If users report some real limitations with providers being singletons > then we can enhance CXF JAX-RS for alternative lifecycles be supported > too. I don't see it being a limitation at the moment... > > Cheers, Sergey > > -Original Message- > From: Mike O'Neil [mailto:mton...@gmail.com] > Sent: 17 December 2009 21:38 > To: users@cxf.apache.org > Subject: Re: How do I access the request URI from an ExceptionMapper? > > Sergey, > Unless I am missing something, this solution is not thread safe. Is > there a way to have ExceptionMapper instantiated as a prototype bean? > Otherwise I don't see how this will work properly across more than 1 > thread. But maybe I am wrong... looking forward to your clarification > :) > > Thanks, > Mike > > On Thu, Dec 17, 2009 at 4:31 PM, Henrik Martin > wrote: >> Thanks Sergey. That worked great. Cheers, >> >> /Henrik >> >> On Thu, 2009-12-17 at 09:33 +, Sergey Beryozkin wrote: >>> Hi >>> >>> You can have a >>> >>> @Context >>> private UriInfo uriInfo; >>> >>> or >>> >>> private UriInfo uriInfo; >>> @Context >>> public void setUriInfo(UriInfo uriInfo) {...} >>> >>> declared in your mapper class... >>> cheers, Sergey >>> >>> - Original Message - >>> From: "Henrik Martin" >>> To: >>> Sent: Thursday, December 17, 2009 12:14 AM >>> Subject: How do I access the request URI from an ExceptionMapper? >>> >>> >>> > Greetings. I have written a bunch of ExceptionMapper > implementations to >>> > catch a variety of business exceptions in our system and return > them as >>> > a special type of Response object. It works fine, but I need to get > a >>> > hold of the URI from the incoming request to set it in the outgoing >>> > Response. Since the ExceptionMapper interface method toResponse() > only >>> > gives me the actual Exception that was thrown, is there another way > I >>> > can get the URI? Thanks, >>> > >>> > /Henrik >> >
Re: Fault thrown in Rest In-Interceptor not handled by ExceptionMapper
Thanks all. CustomOutFaultInterceptor + ResponseHandler handles all use cases nicely for me. But, I notice the incoming Message to both is missing most properties. In particular, QUERY_STRING is not set. I need this to generate proper output in my application. I imagine in ResponseHandler I can use @Context (UrlInfo) to access it, but what about in the OutFault interceptor? Am I out of luck on this one? Thanks, Mike On Thu, Dec 17, 2009 at 6:25 PM, vickatvuuch wrote: > > one more gotcha I hit with this is that SOAP Flex client can't handle > HTTP response other than 200. If you reply with HTTP 500 it completely > ignores your Soap fault, giving a useless IOError instead of SoapFault.. > > > Mike O'Neil-2 wrote: >> >> Thanks for your response. I gave this a shot and it seems to work >> pretty well, though is a lot more cumbersome, seeing as how we need to >> handle the marshalling directly. Unfortunately this also introduces a >> different place where an exception is not properly handled: when >> trying to find the target method in JAXRSUtils, if not found, a >> WebApplicationException is thrown but the custom fault out interceptor >> is not invoked. This results in an empty body in the HTTP response. >> Have you run into that? >> >> Thanks for your help, >> Mike >> >> On Thu, Dec 17, 2009 at 3:25 PM, vickatvuuch wrote: >>> >>> I have had a similar problem and worked it around by building a >>> CustomFaultOutInterceptor, >>> which handles everything that gets thrown for both REST and SOAP. Once >>> you >>> have a single place to do it >>> you can translate Exception into HTTP response codes as well as you can >>> enchance >>> the default Soap fault as appropriate. >>> >>> >>> Mike O'Neil-2 wrote: >>>> >>>> I have an ExceptionMapper which handles exceptions from my Rest >>>> service just fine. However when my "In" Interceptor throws a Fault, >>>> the ExceptionMapper does not handle it. Instead I get the standard >>>> (ugly) XML, e.g.: >>>> >>>> error >>>> message >>>> >>>> Is that the expected behavior? My server is set up like: >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> And my interceptor looks like: >>>> >>>> public class MyInterceptor extends AbstractPhaseInterceptor { >>>> public FormatSettingInterceptor() { >>>> super(Phase.PRE_STREAM); >>>> } >>>> >>>> @Override >>>> public void handleMessage(Message message) throws Fault { >>>> throw new Fault("Not handled by ExceptionMapper!"); >>>> } >>>> } >>>> >>>> Any insight or help would be appreciated. >>>> >>>> Much thanks, >>>> Mike >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://old.nabble.com/Fault-thrown-in-Rest-In-Interceptor-not-handled-by-ExceptionMapper-tp26833555p26834406.html >>> Sent from the cxf-user mailing list archive at Nabble.com. >>> >>> >> >> > > -- > View this message in context: > http://old.nabble.com/Fault-thrown-in-Rest-In-Interceptor-not-handled-by-ExceptionMapper-tp26833555p26836759.html > Sent from the cxf-user mailing list archive at Nabble.com. > >
Changing default url to download wsdl
By default a jaxws soap endpoint allows the generated wsdl to be downloaded by putting "?wsdl" after the endpoint address. Does anyone know if this is configurable? Thanks, Mike
Re: How to consume SharePoint Service Response (Java/.NET interop)?
I tried this interceptor below. I added some printlns and saw that the originalXML string was being set correctly. However, that string is not used anywhere so I'm not sure if this is missing some code or not. The end result is that even though I can see that the correct data is available in the handleMessage, using that code below, it doesn't work still. I still get the null List object back. Is there additional code beyond this that is needed to make it work? csaban wrote: > > Oh yes, forgot to mention, another way would be with JAXB is to add an > interceptor and process the stream before the StaxInInterceptor does. > > eg: > > > static class MyInterceptor extends AbstractPhaseInterceptor { > > public MyInterceptor() { > super(Phase.POST_STREAM); > > getBefore().add(StaxInInterceptor.class.getName()); > } > > public void handleMessage(Message msg) throws > org.apache.cxf.interceptor.Fault { > InputStream is = msg.getContent(InputStream.class); > assert is != null; > > try { > byte[] byteContent = > IOUtils.readBytesFromStream(is); > msg.setContent(InputStream.class, new > ByteArrayInputStream(byteContent)); > String encoding = (String) > msg.get(Message.ENCODING); > String originalXML = new > String(byteContent,encoding); > } catch(Exception e) { > //FIXME: handle exception > e.printStackTrace(); > } > > } > } > > > > csaban wrote: >> >> Probably this is late now, but I was facing the same issue. (Sharepoint, >> NTLMv2, List[null]) >> >> Using JAXB GetList always returned null, but switching to XMLBEANS I do >> get the xml content of the getList response. >> >> Hope this helps someone. >> >> -- >> Csaba >> >> >> mmule wrote: >>> >>> Hello, >>> >>> Do you have a solution for this yet? I am facing a similar issue. The >>> CXF is returning null. >>> >>> Please share if you have the solution. >>> >>> Thanks >>> M >>> >> >> > > -- View this message in context: http://old.nabble.com/How-to-consume-SharePoint-Service-Response-%28Java-.NET-interop%29--tp25263932p28288043.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: filtering elements in jaxrs
Jason, The simplest thing to do is simply set only the fields in your bean that the client is interested in, since null fields are ignored by JAXB. I do this programatically via a simple switch statement, where each case calls the proper setter for the field the user is interested in (for instance in a class which converts a ResultSet or a SolrDocument into your bean). Mike On Wed, Apr 28, 2010 at 6:58 PM, KARR, DAVID (ATTSI) wrote: > > -Original Message- > > From: Jason Chaffee [mailto:jchaf...@ebates.com] > > Sent: Wednesday, April 28, 2010 2:45 PM > > To: users@cxf.apache.org > > Subject: filtering elements in jaxrs > > > > I would like the consumer of my API to be able witch fields (elements) > > they actually want returned in an effort to keep the content as small > > as > > possible, similar to what Solr allows in search. What is the best way > > to accomplish this with JAX-RS and CXF? > > When you get down to it, you have to have some way in your service > interface for the client to specify they want this alternate response. > There are numerous ways to do it, either through the request path, or > through additional request parameters. You just have to decide what's > the most convenient strategy between you and the client. There is no > magic here. >
wsdl2java and basic authentication credentials
Hello All, Is there any way to set basic authentication credentials for the wsdl2java executable (or embedded WSDLToJava) when it downloads a WSDL? I would like to be able to parse WSDLs that are password protected. Thanks, Mike -- View this message in context: http://cxf.547215.n5.nabble.com/wsdl2java-and-basic-authentication-credentials-tp5460147p5460147.html Sent from the cxf-user mailing list archive at Nabble.com.
JAXB qualified namespace not working
I apologize if this question has been answered before. I looked and have seen similar questions asked but not need an answer. I have a code first JAX-WS service built with CXF 2.5.2 with a simple login service that takes a LoginType which I've annotated as follows: @XmlRootElement(namespace = "http://mynamespace.com";) @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "LoginType", propOrder = { "loginObjectPayload" }) public class LoginType { @XmlElement(name = "LoginObjectPayload", required = true) public LoginObjectPayload loginObjectPayload; … } The WSDL generated shows that namespace elements are set as qualified: http://schemas.xmlsoap.org/soap/http"; xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:tns="; http://mynamespace.com"; xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"name="MyEndpoint"; targetNamespace="http://mynamepsace";> http://mynamespace"; xmlns:xs=" http://www.w3.org/2001/XMLSchema"; attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://mynamepsace";> … However when I try to send messages to this service via any tool such as soapUI or any given client where I can send in raw XML that looks like: http://schemas.xmlsoap.org/soap/envelope/"; xmlns:mes="http://mynamespace.com";> ... I get an unmarshalling error from CXF. If I remove the qualified namespace from ONLY the LoginRequest element it seems to work fine. This seems like an anomaly to me, can someone tell me why this would occur and what I may be doing wrong? Thanks!
Re: JAXB qualified namespace not working
Sorry that is a typo. The issue is that if I add the mes namespace to the LoginRequest I get an unmarshalling error stating it is not expecting child elements. However if I remove the mes namespace from LoginRequest it works fine (as long as I do not remove the mes namespace from the child elements). So in short it would seem that even though both are in the same namespace, the service does not seem to think that LoginRequest needs to be in a qualified namespace. On Sun, Feb 26, 2012 at 7:50 PM, Glen Mazza wrote: > On 02/26/2012 09:44 PM, Mike Key wrote: > >> … >> >> However when I try to send messages to this service via any tool such as >> soapUI or any given client where I can send in raw XML that looks like: >> >> http://schemas.** >> xmlsoap.org/soap/envelope/ <http://schemas.xmlsoap.org/soap/envelope/>" >> xmlns:mes="http://mynamespace.**com <http://mynamespace.com>"> >> >> >> >> >> ... >> >> >> >> >> >> I get an unmarshalling error from CXF. If I remove the qualified >> namespace >> from ONLY the LoginRequest element it seems to work fine. This seems like >> an anomaly to me, can someone tell me why this would occur and what I may >> be doing wrong? >> >> > Your closing tag for LoginRequest is missing the mes: prefix, I suspect > that is the problem. AFAIK either both or neither elements need to have it. > > Glen > > -- > Glen Mazza > Talend Community Coders - coders.talend.com > blog: www.jroller.com/gmazza > >
Re: Configuring CXF to work with WS-Security
I turned on debugging at the log4j root logger and saw this: 07:06:22,754 DEBUG UsernameTokenProcessor:49 - Found UsernameToken list element 07:06:22,754 DEBUG UsernameTokenValidator:78 - UsernameToken user Mike 07:06:22,754 DEBUG UsernameTokenValidator:79 - UsernameToken password type null 07:06:22,754 DEBUG TimestampProcessor:46 - Found Timestamp list element 07:06:22,754 DEBUG Timestamp:151 - Current time: 2013-01-11T12:06:22.754Z 07:06:22,754 DEBUG Timestamp:156 - Timestamp created: 2013-01-11T12:06:22.738Z 07:06:22,754 DEBUG Timestamp:162 - Timestamp expires: 2013-01-11T12:11:22.738Z 07:06:22,785 DEBUG Timestamp:342 - Validation of Timestamp: Everything is ok Jan 11, 2013 7:06:22 AM org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor checkActions WARNING: Security processing failed (actions mismatch) Jan 11, 2013 7:06:22 AM org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor handleMessage WARNING: org.apache.ws.security.WSSecurityException: An error was discovered processing the header I then tried these changes: 1. Changed the client to send a dummy password in plain text. 2. Put the dummy password into the CXF service's interceptor configuration. 3. Added a CallbackHandler to the service's WSS4JInInterceptor that set the dummy password on the WSPasswordCallback. That passed through the security checks just fine. Do you have any suggestions on how to make UsernameToken validation pass without any password tag? Thanks, Mike On Fri, Jan 11, 2013 at 5:34 AM, Colm O hEigeartaigh wrote: > Hi Mike, > > Turn logging to "DEBUG" and see what the reason for the > "WSSecurityException" was. > > Colm. > > On Thu, Jan 10, 2013 at 9:14 PM, Mike Thomsen >wrote: > > > I'm still fairly new to CXF and Java web services, so please bear with > me. > > The service I am calling expects a WS-Security header like this: > > > > > > http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd > > " > > soapenv:mustUnderstand="1"> > > http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd > > " > > wsu:Id="Timestamp-29345020"> > > 2008-11-24T19:17:43.880Z > > 2008-11-24T19:22:43.880Z > > > > http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd > > " > > wsu:Id="UsernameToken-18724539"> > > Mike > > > > > > > > > > (No password) > > > > This is how I have it configured in my beans.xml file: > > > > > implementor="com.mycompany.ManagementService" > address="/ManagementService"> > > > > > class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"> > > > > > > > > > > > > > > > > > > > > > > When I run the client I get this exception: > > > > org.apache.ws.security.WSSecurityException: An error was discovered > > processing the header > > > > I know the client (Spring-WS, not CXF) is sending WS-Security headers > based > > on the debugging output from it. > > > > Any help would be appreciated. > > > > Thanks, > > > > Mike > > > > > > -- > Colm O hEigeartaigh > > Talend Community Coder > http://coders.talend.com >
Re: Configuring CXF to work with WS-Security
Thanks! That seemed to work. Sent from my iPhone On Jan 11, 2013, at 9:51 AM, Colm O hEigeartaigh wrote: > Try using the action configuration: > > > > Colm. > > On Fri, Jan 11, 2013 at 12:35 PM, Mike Thomsen wrote: > >> I turned on debugging at the log4j root logger and saw this: >> >> 07:06:22,754 DEBUG UsernameTokenProcessor:49 - Found UsernameToken list >> element >> 07:06:22,754 DEBUG UsernameTokenValidator:78 - UsernameToken user Mike >> 07:06:22,754 DEBUG UsernameTokenValidator:79 - UsernameToken password type >> null >> 07:06:22,754 DEBUG TimestampProcessor:46 - Found Timestamp list element >> 07:06:22,754 DEBUG Timestamp:151 - Current time: 2013-01-11T12:06:22.754Z >> 07:06:22,754 DEBUG Timestamp:156 - Timestamp created: >> 2013-01-11T12:06:22.738Z >> 07:06:22,754 DEBUG Timestamp:162 - Timestamp expires: >> 2013-01-11T12:11:22.738Z >> 07:06:22,785 DEBUG Timestamp:342 - Validation of Timestamp: Everything is >> ok >> Jan 11, 2013 7:06:22 AM >> org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor checkActions >> WARNING: Security processing failed (actions mismatch) >> Jan 11, 2013 7:06:22 AM >> org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor handleMessage >> WARNING: >> org.apache.ws.security.WSSecurityException: An error was discovered >> processing the header >> >> I then tried these changes: >> >> 1. Changed the client to send a dummy password in plain text. >> 2. Put the dummy password into the CXF service's interceptor configuration. >> 3. Added a CallbackHandler to the service's WSS4JInInterceptor that set >> the dummy password on the WSPasswordCallback. >> >> That passed through the security checks just fine. Do you have any >> suggestions on how to make UsernameToken validation pass without any >> password tag? >> >> Thanks, >> >> Mike >> >> >> On Fri, Jan 11, 2013 at 5:34 AM, Colm O hEigeartaigh >> wrote: >> >>> Hi Mike, >>> >>> Turn logging to "DEBUG" and see what the reason for the >>> "WSSecurityException" was. >>> >>> Colm. >>> >>> On Thu, Jan 10, 2013 at 9:14 PM, Mike Thomsen >>> wrote: >>> >>>> I'm still fairly new to CXF and Java web services, so please bear with >>> me. >>>> The service I am calling expects a WS-Security header like this: >>>> >>>> >>>>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd >>>> " >>>> soapenv:mustUnderstand="1"> >>>>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd >>>> " >>>> wsu:Id="Timestamp-29345020"> >>>>2008-11-24T19:17:43.880Z >>>>2008-11-24T19:22:43.880Z >>>> >>>>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd >>>> " >>>> wsu:Id="UsernameToken-18724539"> >>>>Mike >>>> >>>> >>>> >>>> >>>> (No password) >>>> >>>> This is how I have it configured in my beans.xml file: >>>> >>>> >>> implementor="com.mycompany.ManagementService" >>> address="/ManagementService"> >>>> >>>>>>> class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor"> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> When I run the client I get this exception: >>>> >>>> org.apache.ws.security.WSSecurityException: An error was discovered >>>> processing the header >>>> >>>> I know the client (Spring-WS, not CXF) is sending WS-Security headers >>> based >>>> on the debugging output from it. >>>> >>>> Any help would be appreciated. >>>> >>>> Thanks, >>>> >>>> Mike >>> >>> >>> >>> -- >>> Colm O hEigeartaigh >>> >>> Talend Community Coder >>> http://coders.talend.com > > > -- > Colm O hEigeartaigh > > Talend Community Coder > http://coders.talend.com
Adding custom HTTP header to SOAP request causes bad SOAPAction to be sent
I am trying to consume a SOAP webservice with CXF served by .NET WCF. I used wsimport to create the Java client objects. We have a custom http tunnel that routes based on info in an extra http header field. When trying to use the tunnel I was getting errors from WCF (so I know the header is added ok). I took the tunnel out of the picture and passed a dummy ID via a direct connection and there is still the same error. When I remove the dummy ID from the header everything works as I expect (via the direct connection). Here's how I'm creating my proxy object: JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(IMikesService.class); factory.setAddress("http://example.com/mikesservice";); IMikesService proxy = (IMikesService)factory.create(); Here's how I'm adding the extra header field: BindingProvider bp = (BindingProvider)proxy; Map> headers = new HashMap>(); headers.put("MikesCustomHeader", Arrays.asList("myValue")); bp.getRequestContext().put(Message.PROTOCOL_HEADERS, headers); (For the following I exclude the namespaces found in the Soap XML payload for brevity.) With the extra header, the SOAP action header field doesn't match the SOAP message payload. For example, the SOAP action may be for Op1 but the SOAP body has a element. I know this after snooping in with Wireshark. If I don't pass the extra header, everything lines up ok and the SOAP request works. It's worth noting that the way this webservice is used that Op1 is called before Op2 fails on the same proxy object. I have not yet made a test app to test this tunnel stuff with different SOAP methods on their own. That is one of my next steps. Am I missing anything? Is this a known issue? I found something about needing to use multi value map objects for custom headers but that supposedly was fixed in the 2.3 or 2.4 series. Plus I know it was getting through our tunnel since I got WCF SOAP parsing errors back (the tunnel server does not expose the service on its own, just handles routing). I'm using CXF 2.5.0 and as I wrote this I saw there's a 2.5.1 out. I didn't see anything relevant in the release notes, but that's something else I'll try. Thanks! Mike Hurley Software Engineer mhur...@renovosoftware.com<mailto:mhur...@renovosoftware.com> www.renovosoftware.com<http://www.renovosoftware.com/> [cid:image001.jpg@01CCD5CF.F3EA0AD0]
RE: Adding custom HTTP header to SOAP request causes bad SOAPAction to be sent
Here's an update: * Using a separate client app I confirmed that Op2 on its own will work with the custom header. Problems come up when it's after another call on the same proxy object. * Creating a new proxy object between calls fixes the problem. CXF seems to be caching stuff between calls when there are extra HTTP headers. o Creating new proxies makes this work with our tunnel server too (which needs the custom header). * CXF 2.5.0 and 2.5.1 behave the same Before I enter a defect against CXF, I guess I'd like someone to confirm the way I'm using CXF is correct, make sure it's not user error. Thanks, Mike From: Mike Hurley [mailto:mhur...@renovosoftware.com] Sent: Wednesday, January 18, 2012 11:19 AM To: users@cxf.apache.org Subject: Adding custom HTTP header to SOAP request causes bad SOAPAction to be sent I am trying to consume a SOAP webservice with CXF served by .NET WCF. I used wsimport to create the Java client objects. We have a custom http tunnel that routes based on info in an extra http header field. When trying to use the tunnel I was getting errors from WCF (so I know the header is added ok). I took the tunnel out of the picture and passed a dummy ID via a direct connection and there is still the same error. When I remove the dummy ID from the header everything works as I expect (via the direct connection). Here's how I'm creating my proxy object: JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(IMikesService.class); factory.setAddress("http://example.com/mikesservice";); IMikesService proxy = (IMikesService)factory.create(); Here's how I'm adding the extra header field: BindingProvider bp = (BindingProvider)proxy; Map> headers = new HashMap>(); headers.put("MikesCustomHeader", Arrays.asList("myValue")); bp.getRequestContext().put(Message.PROTOCOL_HEADERS, headers); (For the following I exclude the namespaces found in the Soap XML payload for brevity.) With the extra header, the SOAP action header field doesn't match the SOAP message payload. For example, the SOAP action may be for Op1 but the SOAP body has a element. I know this after snooping in with Wireshark. If I don't pass the extra header, everything lines up ok and the SOAP request works. It's worth noting that the way this webservice is used that Op1 is called before Op2 fails on the same proxy object. I have not yet made a test app to test this tunnel stuff with different SOAP methods on their own. That is one of my next steps. Am I missing anything? Is this a known issue? I found something about needing to use multi value map objects for custom headers but that supposedly was fixed in the 2.3 or 2.4 series. Plus I know it was getting through our tunnel since I got WCF SOAP parsing errors back (the tunnel server does not expose the service on its own, just handles routing). I'm using CXF 2.5.0 and as I wrote this I saw there's a 2.5.1 out. I didn't see anything relevant in the release notes, but that's something else I'll try. Thanks! Mike Hurley Software Engineer mhur...@renovosoftware.com<mailto:mhur...@renovosoftware.com> www.renovosoftware.com<http://www.renovosoftware.com/> [cid:image001.jpg@01CCD5CF.F3EA0AD0]
RE: Adding custom HTTP header to SOAP request causes bad SOAPAction to be sent
I have added a new issue. https://issues.apache.org/jira/browse/CXF-4046 Thanks, Mike -Original Message- From: Glen Mazza [mailto:gma...@talend.com] Sent: Wednesday, January 18, 2012 4:05 PM To: users@cxf.apache.org Subject: Re: Adding custom HTTP header to SOAP request causes bad SOAPAction to be sent Mike, can you submit a JIRA with a very simple test client & WSP that quickly reproduces the problem? One way of doing this is to download my minimal DoubleIt Web Service & Client (http://www.jroller.com/gmazza/entry/web_service_tutorial) which quickly runs OOTB on Tomcat and make whatever modifications to the client that reproduce this bug, and then attach it to the JIRA. You will probably need to add an additional operation ("TripleIt" perhaps) to the WSP's WSDL to replicate this issue. Thanks, Glen
Aegis, setDefaultNillable() and null return
Hi, I'm using CXF with Aegis databinding and a CXFNonSpringServlet. My SEI and some parts of the data classes are annotated using JAXB annotations. I use the following Aegis type config: tOpts.setDefaultNillable(false); tOpts.setDefaultMinOccurs(1); But when I set these options, I can't return nil from my webservice methods anymore. Does anyone know if there is an annotation I can set to allow null/nil returns from a service method? -- Regards, Mike Noordermeer m...@normi.net
Re: Aegis, setDefaultNillable() and null return
Benson Margulies wrote: I think I need a much more detailed test case to make sense of this. However, what you appear to have stated is that, unless you declare a particular item to be nillable, it can't be null. Thanks for your reply, sorry for the confusion. The basic question is: how do I declare a return value (of a service method) to be nillable when using Aegis? -- Regards, Mike Noordermeer m...@normi.net
Re: Aegis, setDefaultNillable() and null return
Hi, Benson Margulies wrote: In theory, with a WHATEVER.aegis.xml file. I don't see a unit test that does this, so feel free to squawk if it doesn't work. Thanks, doesn't seem to work though :-( Aegis finds the mapping file: 2596 [ContainerBackgroundProcessor[StandardEngine[Catalina]]] TRACE org.apache.cxf.aegis.type.XMLTypeCreator - Found mapping file : /nl/eveoh/scheduleviewer/services/UserPreferencesService.aegis.xml But it doesn't return a null value, it returns: xmlns:ns1="http://services.scheduleviewer.eveoh.nl/"/> instead of: xmlns:ns1="http://services.scheduleviewer.eveoh.nl/"; xmlns:ns2="http://www.w3.org/2001/XMLSchema-instance"/> Any ideas? If not I guess I'll have to not use setDefaultNillable(false) and just tag everything that's non-nillable. -- Regards, Mike Noordermeer m...@normi.net
Failing to drop inbound XML element with invalid content
Hi, I'm using CXF in a client that is consuming the MS Exchange Web Service (EWS). I'm finding that one of the elements returned by this service (UniqueHash) contains characters that are invalid in XML v1.0. As I have no control over this I'm trying to use an inbound interceptor to drop the UniqueHash elements (I don't need them) like this: Map inTransformMap = Collections.singletonMap( "{http://schemas.microsoft.com/exchange/services/2006/types}UniqueHash";, ""); TransformInInterceptor transformInInterceptor = new TransformInInterceptor(); transformInInterceptor.setInTransformElements(inTransformMap); client.getInInterceptors().add(transformInInterceptor); I can see that the transform is running nice and early (post-stream): FINE: Chain org.apache.cxf.phase.PhaseInterceptorChain@be78549 was created. Current flow: receive [PolicyInInterceptor, LoggingInInterceptor, AttachmentInInterceptor] post-stream [TransformInInterceptor, StaxInInterceptor] read [WSDLGetInterceptor, ReadHeadersInterceptor, SoapActionInInterceptor, StartBodyInterceptor] pre-protocol [MustUnderstandInterceptor] post-protocol [CheckFaultInterceptor, JAXBAttachmentSchemaValidationHack] unmarshal [DocLiteralInInterceptor, SoapHeaderInterceptor] post-logical [WrapperClassInInterceptor] pre-invoke [SwAInInterceptor, HolderInInterceptor] But even though it *appears* to be working as intended stepping through the code, when DocLiteralInInterceptor fires later on it throws this unmarshalling error (0x5 in this case is within the UniqueHash element I thought I'd dropped): org.apache.cxf.interceptor.Fault: Unmarshalling Error: Illegal character entity: expansion character (code 0x5 at [row,col {unknown-source}]: [1,2574] at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:881) at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:702) at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:160) at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:192) Does anyone know what I'm doing wrong here? Any pointers on how I get rid of this element and it's troublesome content? BTW I'm using CXF v2.7.10 with Java 7. Kind regards, Mike
Re: Failing to drop inbound XML element with invalid content
Thanks Daniel. I worked that out about an hour ago and am implementing it now! Thanks for the quick reply though. It's a shame there's not an out of the box interceptor for this as it's probably a pretty common use case. Regards Mike On 18/03/2014 9:06 AM, "Daniel Kulp" wrote: > > Using a transform for this won't work as the XML parser (woodstox in our > case) would still not be able to parse the XML. > > The only way to handle this would be to write an interceptor that would > run prior to the StaxInInterceptor that would take the InputSteam and > wrapper it with a new InputStream that would convert the bytes to valid > values during the read(..) methods. Basically, fix it at the stream level. > > Dan > > > On Mar 17, 2014, at 4:39 AM, Mike Watson > wrote: > > > Hi, > > > > I'm using CXF in a client that is consuming the MS Exchange Web Service > > (EWS). > > > > I'm finding that one of the elements returned by this service > (UniqueHash) > > contains characters that are invalid in XML v1.0. As I have no control > over > > this I'm trying to use an inbound interceptor to drop the UniqueHash > > elements (I don't need them) like this: > > > > Map inTransformMap = Collections.singletonMap( > > "{http://schemas.microsoft.com/exchange/services/2006/types}UniqueHash";, > > ""); > > TransformInInterceptor transformInInterceptor = new > > TransformInInterceptor(); > > transformInInterceptor.setInTransformElements(inTransformMap); > > client.getInInterceptors().add(transformInInterceptor); > > > > > > I can see that the transform is running nice and early (post-stream): > > > > FINE: Chain org.apache.cxf.phase.PhaseInterceptorChain@be78549 was > created. > > Current flow: > > receive [PolicyInInterceptor, LoggingInInterceptor, > > AttachmentInInterceptor] > > post-stream [TransformInInterceptor, StaxInInterceptor] > > read [WSDLGetInterceptor, ReadHeadersInterceptor, > > SoapActionInInterceptor, StartBodyInterceptor] > > pre-protocol [MustUnderstandInterceptor] > > post-protocol [CheckFaultInterceptor, > JAXBAttachmentSchemaValidationHack] > > unmarshal [DocLiteralInInterceptor, SoapHeaderInterceptor] > > post-logical [WrapperClassInInterceptor] > > pre-invoke [SwAInInterceptor, HolderInInterceptor] > > > > > > But even though it *appears* to be working as intended stepping through > the > > code, when DocLiteralInInterceptor fires later on it throws this > > unmarshalling error (0x5 in this case is within the UniqueHash element I > > thought I'd dropped): > > > > org.apache.cxf.interceptor.Fault: Unmarshalling Error: Illegal character > > entity: expansion character (code 0x5 > > at [row,col {unknown-source}]: [1,2574] > > at > > > org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:881) > > at > > > org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:702) > > at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:160) > > at > > > org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:192) > > > > Does anyone know what I'm doing wrong here? Any pointers on how I get rid > > of this element and it's troublesome content? > > > > BTW I'm using CXF v2.7.10 with Java 7. > > > > Kind regards, > > Mike > > -- > Daniel Kulp > dk...@apache.org - http://dankulp.com/blog > Talend Community Coder - http://coders.talend.com > >
cxf-codegen-plugin 3.2.4 Error in POM
/confluence/display/MAVEN/MojoExecutionException *Mike Oliver** Founder**, Open 4 Business Online* Tel: +1(951)260-0793 | Mobile:**NEW* 639479927462 US Toll free: 1-800-985-4766 **NEW* http://www.o4bo.com Mas marunong akong umunawa ng salitang tagalog kaysa magkapagsalita nito [image: Facebook] <http://www.facebook.com/pages/Open-4-Business-Online/147285608707176> [image: Twitter] <https://twitter.com/O4BO> [image: LinkedIn] <http://ph.linkedin.com/pub/mike-oliver/0/1b9/197> [image: AngelList] <https://angel.co/open-4-business-online/> [image: Blogger] <http://blog.open4businessonline.com/> [image: eBay] <http://www.store.o4bo.com/servlet/StoreFront> [image: YouTube] <http://www.youtube.com/channel/UCruaIEFosh9uvfkQCq7mtKw> [image: Google Plus Page] <https://plus.google.com/113688478700619104336/posts> Contact me: [image: Google Talk] mikeolive...@open4businessonline.com [image: Skype] MikeOliverAZ