[ https://issues.apache.org/jira/browse/CXF-4075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13196326#comment-13196326 ]
Nathan Gulley commented on CXF-4075: ------------------------------------ Thanks Sergey. I followed your suggestion and was able to get the "forgotPassword" web service call to succeed by abdding a custom jaxbProvider to the spring config (see below). However the "resetPassword" web service call is still failing with a similar error: org.apache.cxf.jaxrs.client.ClientWebApplicationException: Problem with reading the response message, class : class com.sears.login.LoginResponse, ContentType : text/plain. CAUSE: javax.ws.rs.WebApplicationException: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"ResetPassword"). Expected elements are <{}LoginRespData>,<{}LoginResponse>,<{}RespMessage>,<{}ResponseCode>,<{}ServiceHeaders>,<{}StatusData>,<{}clientSessionKey>,<{}globalID>,<{}store> DETAILED MESSAGE: Problem with reading the response message, class : class com.sears.login.LoginResponse, ContentType : text/plain. ------------- Response Content ------------- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <LoginResponse> <LoginRespData> <clientSessionKey>0000XBGelFwQDCIeDd8og6RhoPW:15ba97k18</clientSessionKey> <globalID>31515333</globalID> </LoginRespData> <StatusData> <ResponseCode>0</ResponseCode> <RespMessage>LOGIN SUCCESSFUL</RespMessage> </StatusData> <ServiceHeaders> <store>10153</store> </ServiceHeaders> </LoginResponse> -------------- Spring configuration -------------------------- <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider"> <property name="consumeMediaTypes"> <list> <value>text/plain</value> <value>text/xml</value> <value>application/xml</value> </list> </property> </bean> <jaxrs:client id="shcProfileService" address="https://webservices.sears.com:" serviceClass="com.sears.mobilegateway.service.SHCProfileService" inheritHeaders="true"> <jaxrs:providers> <ref bean="jaxbProvider" /> </jaxrs:providers> <jaxrs:headers> <entry key="Accept" value="text/xml"/> <entry key="Accept" value="text/plain"/> </jaxrs:headers> </jaxrs:client> > The JAX-RS : Client API Unable to Handle Response Content Type "text/plain". > Throws ClientWebApplicationException When Client Service Method is Invoked > ------------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: CXF-4075 > URL: https://issues.apache.org/jira/browse/CXF-4075 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 2.5 > Environment: OS: Windows XP > JDK Version: 6 > Reporter: Nathan Gulley > Priority: Critical > Fix For: Invalid > > > The JAX-RS : Client API is unable to handle response content type > "text/plain". The proxy client throws a ClientWebApplicationException > when the service call is made: > org.apache.cxf.jaxrs.client.ClientWebApplicationException: .No message body > reader has been found for class : class > com.sears.forgotpassword.ForgotPassword, ContentType : text/plain. > at > org.apache.cxf.jaxrs.client.AbstractClient.reportMessageHandlerProblem(AbstractClient.java:593) > at > org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:445) > at > org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:527) > at > org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:487) > at > org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:188) > at $Proxy16.forgotPassword(Unknown Source) > at > com.sears.mobilegateway.test.SHCAPIProfileServiceTest.testForgotPassword(SHCAPIProfileServiceTest.java:231) > WEB SERVICE URL: > http://webservices.sears.com/shcapi/ForgotPassword?store=Sears&appID=MOB_IPH_SEARS_2GO&authID=mrktplcC91F7F1DE2CE3F675A65C172B944C37301202010&langId=-1&catalogId=12605&email=ngul23as19...@yahoo.com > RESPONSE CONTENT TYPE: text/plain > RESPONSE CONTENT: > <?xml version="1.0" encoding="UTF-8" standalone="no" ?> > <ForgotPassword> > <StatusData> > <ResponseCode>0</ResponseCode> > <RespMessage><![CDATA[Action is successful.Please check your > email account for instructions on how to choose your new > password.]]></RespMessage> > </StatusData> > <ServiceHeaders> > <Store> 10153 </Store> > <LangId> -1 </LangId> > <clientSessionKey> 3uDXyoc2vtZi35gk3UVdyOC > </clientSessionKey> > </ServiceHeaders> > </ForgotPassword> > Here are the detailed steps you need to follow in order to reproduce the bug: > 1. Define a REST client service class that points to a RESTful web service > that returns content type "text/plain" > CLASS: import javax.ws.rs.GET; > import javax.ws.rs.POST; > import javax.ws.rs.Path; > import javax.ws.rs.QueryParam; > import com.sears.forgotpassword.ForgotPassword; > public interface SHCAPIProfileService { > @Path("/shcapi/ForgotPassword") @GET > public ForgotPassword forgotPassword(@QueryParam("email") String > email, > @QueryParam("appID") String > appID, > @QueryParam("authID") String > authID, > @QueryParam("store") String > store, > @QueryParam("catalogId") String > catalogId, > @QueryParam("langId") String > langId); > } > 2. Add the service class to your Spring configuration file as a CXF JAX-RS > client bean. Configure the bean to accept content type > "text/plain": > <jaxrs:client id="shcapiProfileService" > address="https://webservices.sears.com:" > serviceClass="com.sears.mobilegateway.service.SHCAPIProfileService" > inheritHeaders="true"> > <jaxrs:headers> > <entry key="Accept" value="text/plain"/> > <entry key="Accept" value="text/xml"/> > </jaxrs:headers> > </jaxrs:client> > 3. Use a Spring ApplicationContext to reference an instance of the client > service bean in your code: > > ApplicationContext applicationContext = new > ClassPathXmlApplicationContext("spring-business-context.xml"); > SHCAPIProfileService shcapiProfileService = > (SHCAPIProfileService)applicationContext.getBean("shcapiProfileService"); > 4. Call the "forgotPassword" service method on the service class: > ForgotPassword responseObj = shcapiProfileService.forgotPassword(LOGIN_ID, > APP_ID, AUTH_ID, STORE, CATALOG_ID, LANG_ID); > > 5. The following ClientWebApplicationException is thrown when JAXB tries to > unmarshall the response content into the "ForgotPassword" Java object: > org.apache.cxf.jaxrs.client.ClientWebApplicationException: .No message body > reader has been found for class : class > com.sears.forgotpassword.ForgotPassword, ContentType : text/plain. > at > org.apache.cxf.jaxrs.client.AbstractClient.reportMessageHandlerProblem(AbstractClient.java:593) > at > org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:445) > at > org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:527) > at > org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:487) > at > org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:188) > at $Proxy16.forgotPassword(Unknown Source) > at > com.sears.mobilegateway.test.SHCAPIProfileServiceTest.testForgotPassword(SHCAPIProfileServiceTest.java:231) > > NOTE: This exception should not occur since we configured the service class > to accept content type "text/plain" in step 2. > I tried work arounds such as customizing the proxy by running the > following code before making the client service call: > WebClient.client(shcapiProfileService).accept("text/plain"); > However these had no effect. The same error occurs. > -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira