The problem is you have registered jacksonjson parser but the content type you 
are sending is text/html.

One solution could be set the appropriate Accept header and content type:
        webClient.accept(MediaType.APPLICATION_JSON);
        webClient.type(MediaType.APPLICATION_JSON);


And if you want to do the same using xml then register jaxb parser and set 
content type to application/xml.
        webClient.accept MediaType.APPLICATION_XML);
        webClient.type MediaType.APPLICATION_XML);

Try this out and please let me know the results.

Regards,
Abhishek

-----Original Message-----
From: amathewcxf [mailto:[email protected]] 
Sent: Tuesday, June 05, 2012 6:32 AM
To: [email protected]
Subject: RE: How to use XSD file with cxf

Thank You Abhishek. Very much appreciated your time/reply.

I was able to move forward quiet a bit. Below are my classes now:


Class 1: GetAvailabilityTest => A  JUNIT client file

public class GetAvailabilityTest {

    @Autowired
        private GetAvailabilityService getAvailabilityService;
        
        @Test
        public void testGetAvailability() throws Exception {
                
                if(this.getAvailabilityService != null){
                        try{
                        WebClient   webClient = 
WebClient.create("https://mywsremoteurl:8080";,
Collections.singletonList(new JacksonJsonProvider()));
                HTTPConduit conduit =
WebClient.getConfig(webClient).getHttpConduit();
               
conduit.setTlsClientParameters(getConfiguredClientSSLParms(webClient));
                this.getAvailabilityService.getAvailability(webClient, 1146);
                
                        }catch(Throwable e){
                                System.out.println("Error in 
testGetAvailability:" + e);
                        }
                        
                }
        }
        
    protected TLSClientParameters getConfiguredClientSSLParms(WebClient
client) {
        
        TLSClientParameters params =
WebClient.getConfig(client).getHttpConduit().getTlsClientParameters();
        TrustManager[] trustAllCerts = new TrustManager[] { new
X509TrustManager() {
               public java.security.cert.X509Certificate[]
getAcceptedIssuers() {
                     return null;
               }

               public void
checkClientTrusted(java.security.cert.X509Certificate[] certs, String
authType) {
               }

               public void
checkServerTrusted(java.security.cert.X509Certificate[] certs, String
authType) {
               }
        } };
        if (params == null) {
               params = new TLSClientParameters();
               params.setDisableCNCheck(true);
               params.setSecureSocketProtocol("SSL");
        }

        params.setTrustManagers(trustAllCerts);
        return params;       
 }

}

--------------------------------------
Class 2: GetAvailabilityServiceImpl.java

@Path("/ws-api/availability/v1")
public class GetAvailabilityServiceImpl implements GetAvailabilityService{
 
        @GET
        public Availability getAvailability(WebClient webClient,
@QueryParam("eventId") int eventId){
                Availability avail = webClient.get(Availability.class);
                
                return avail;
        }
}

-------------------

Interface - GetAvailabilityService.java

@Path("/ws-api/availability/v1")
public interface GetAvailabilityService {

        @GET
        public Availability getAvailability(WebClient webClient,
@QueryParam("eventId") int eventId);
}

----

Class which i generated from xsd using JAXB

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "availability", propOrder = {
    "event",
    "groups"
 })
@XmlRootElement 
public class Availability {

    protected SimpleDomainBean event;
    protected Groups groups;

    /**
     * Gets the value of the event property.
     * 
     * @return
     *     possible object is
     *     {@link SimpleDomainBean }
     *     
     */
    public SimpleDomainBean getEvent() {
        return event;
    }

    /**
     * Sets the value of the event property.
     * 
     * @param value
     *     allowed object is
     *     {@link SimpleDomainBean }
     *     
     */
    public void setEvent(SimpleDomainBean value) {
        this.event = value;
    }

    /**
     * Gets the value of the groups property.
     * 
     * @return
     *     possible object is
     *     {@link Groups }
     *     
     */
    public Groups getGroups() {
        return groups;
    }

    /**
     * Sets the value of the groups property.
     * 
     * @param value
     *     allowed object is
     *     {@link Groups }
     *     
     */
    public void setGroups(Groups value) {
        this.groups = value;
    }


}


When i run this JUNIT test client, I am getting the below error:

INFO: Problem with setting the default provider
org.apache.cxf.jaxrs.provider.JSONProviderorg/codehaus/jettison/mapped/TypeConverter
Jun 4, 2012 5:50:23 PM org.apache.cxf.jaxrs.provider.ProviderFactory
createProvider

INFO: Problem with setting the default provider
org.apache.cxf.jaxrs.provider.JSONProviderorg/codehaus/jettison/mapped/TypeConverter
Jun 4, 2012 5:50:29 PM org.apache.cxf.jaxrs.client.AbstractClient
reportMessageHandlerProblem
SEVERE: .No message body reader has been found for class : class
com.tickets.ws.availability.Availability, ContentType :
text/html;charset=utf-8.

Error in
testGetAvailability:org.apache.cxf.jaxrs.client.ClientWebApplicationException:
.No message body reader has been found for class : class
com.tickets.ws.availability.Availability, ContentType :
text/html;charset=utf-8.


You may notice that I am alreading including the JacksonJsonProvider in the
WebClient.create method and also i have the @XmlRootElement in the
Availability.java.

Any thoughts on this will be helpful to me.

Thank You

Anil Mathew


--
View this message in context: 
http://cxf.547215.n5.nabble.com/How-to-use-XSD-file-with-cxf-tp5708311p5709079.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to