camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sriraman Gopalan <sreeraa...@gmail.com>
Subject Camel CXF component - Adding custom context classes via the uri options
Date Sat, 26 Jan 2013 07:37:47 GMT
Dear All,

We use the camel - cxf component to invoke external web services. We use the
uri format with options to set various attributes as shown below:

cxf://<url>?serviceName=<serviceName>&portName=<portName>&wsdlURL=<wsdlURL>&defaultOperationName=<defaultOperationName>&serviceClass=<serviceClass>

This works well for most cases without any issues. However, the issue is
with one of the web services wherein for one operation's response , one of
the element's type is marked as xsd:any which resulted in the generated
classes having Object as the attribute type.

wsdl snippet:

<s:element name="GetWTDataResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="GetWTDataResult">
              <s:complexType>
                <s:sequence>
                  
                  <s:any />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>

Generated Java Code Snippet:

public static class GetWTDataResult {

        @XmlAnyElement(lax = true)
        protected Object any;

       
        public Object getAny() {
            return any;
        }

      
        public void setAny(Object value) {
            this.any = value;
        }

    }


While invoking the actual service ( a .NET web service), the response comes
with the xsd and the data.

Actual web service response snippet:

<GetWTDataResponse xmlns="http://tempuri.org/">
      <GetWTDataResult>
        <xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
          <xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
            <xs:complexType>
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="Table">
                  <xs:complexType>
                    <xs:sequence>
                      <xs:element name="InsType" type="xs:string"
minOccurs="0"/>
                      <xs:element name="MarketVal" type="xs:double"
minOccurs="0"/>
                      <xs:element name="InvestAmount" type="xs:double"
minOccurs="0"/>
                      <xs:element name="TransDate" type="xs:dateTime"
minOccurs="0"/>
                    </xs:sequence>
                  </xs:complexType>
                </xs:element>
              </xs:choice>
            </xs:complexType>
          </xs:element>
        </xs:schema>
        <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
          <NewDataSet xmlns="">
            

              <InsType>Equity</InsType>
              <MarketVal>6626</MarketVal>
              <InvestAmount>14947.77</InvestAmount>
              <TransDate>2013-01-25T15:52:00+05:30</TransDate>
            

          </NewDataSet>
        </diffgr:diffgram>
      </GetWTDataResult>
    </GetWTDataResponse>


To make jaxb aware of this element "NewDataSet", we generated the jaxb
classes from the xsd in the web service response as shown above using
maven-jaxb2-plugin.

Now, the issue is how do we make this custom jaxb classes available to cxf
so that it correctly deserializes the response?

After searching the net, we found that this can be accomplished via code as
shown in the following link:

progress documentation
<http://documentation.progress.com/output/Iona/artix/5.1/jaxws_pguide/JAXWSDataMappingOverMoreClasses.html>
 

Since, we are using camel cxf component, is there any other way to indicate
to cxfendpoint to use these extra jaxb classes?

I did notice that the camel cxf component allows setting of custom cxf
properties via the properties.XXX format.

However, I am not too sure how to set this for the
jaxb.additionalContextClasses property which is a property in the
jaxwsproxyfactory bean.

Any help would be highly appreciated.

best regards
Sriraman.




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-CXF-component-Adding-custom-context-classes-via-the-uri-options-tp5726313.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message