I Appreciate your efforts in getting it done and sharing the same :)

One Q related to MappedNamespaceConvention provider: 

I used Jackson provider explicitly as I was getting some problem with the 
default json provider in CXF as it was creating an unnecessary wrapper for the 
root element. 

So when you publish your schema the json may or may not contain additional 
wrapper.

Which one is syntactically correct as different parsers have different 
behaviors?

For e.g.:
Sample XML:

<MMTHotelAvailRequest>
<POS>
<Requestor type="B2BAgent" idContext="FPH" id="AFF0987" channel="B2C"/>
<Source iSOCurrency="INR"/>
</POS>
</MMTHotelAvailRequest>

JSON1 (thru CXF):
{
  "MMTHotelAvailRequest": {
    "POS": {
      "Requestor": {
        "type": "B2BAgent",
        "idContext": "FPH",
        "id": "AFF0987",
        "channel": "B2C"
      },
      "Source": { "iSOCurrency": "INR" }
    }
  }
}

JSON2 (thru Jackson):
{
  "POS" : {
    "Requestor" : {
      "channel" : "Mobile",
      "id" : "AFF0987",
      "idContext" : "MMT",
      "type" : "MobileAgent"
    },
    "Source" : {"iSOCurrency" : "INR"
    }
  }
}

Thanks,
Abhishek

-----Original Message-----
From: amathewcxf [mailto:[email protected]] 
Sent: Saturday, June 09, 2012 12:02 AM
To: [email protected]
Subject: RE: How to use XSD file with cxf

Thank you Abhishek for all the help. I have it all working with WebClient &
JSON as the type.

Below is my final client code (I am posting so it may help others in the
forum):

                try {
                        WebClient webClient =
WebClient.create("https://myremotws.com:18443/availability/v1?eventId=1146";,
Collections.singletonList(new MappedNamespaceConvention(new
Configuration())));
                        String authorizationHeader = "Basic " +
org.apache.cxf.common.util.Base64Utility.encode("myusername:mypassword".getBytes());
                        webClient.header("Authorization", authorizationHeader);
                        webClient.accept(MediaType.APPLICATION_JSON);

                        // This section of code will make sure client is 
treated as a Trusted
source by remote service
                        // and this is needed only if the remote server doesnt 
have a valid
certificate
                        HTTPConduit conduit = 
WebClient.getConfig(webClient).getHttpConduit();
                        
conduit.setTlsClientParameters(getConfiguredClientSSLParms(webClient));
                        
                        // This will make the exact remote webservice all to 
get the response
                        // The response data will be JSON String and the above 
provider
(MappedNamespaceConvention) which 
                        // we registered will take care of all JSON parsing to 
our JAXB classes.
                        Availability avail = webClient.get(Availability.class);

                } catch (Throwable e) {
                        
                }

Thanks
Anil Mathew

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

Reply via email to