Hi,
You can inject extra classes into jaxb context both for the client and server side. I''ll show the example how to do it with client side(server side isn't much difference)

JaxWsClientFactoryBean cfBean = new JaxWsClientFactoryBean();
cfBean.setAddress("http://localhost/Hello";);
cfBean.setBus(getBus());
cfBean.setServiceClass(HelloService.class);
Map props = cfBean.getProperties();
if (props == null) { props = new HashMap<String, Object>(); } }
props.put("jaxb.additionalContextClasses",
new Class[] {com.test.SimpleObject, com.test.AnotherSimpleObject});
cfBean.setProperties(props);
Client client = cfBean.create();


You can also do it with spring configuration like

<jaxws:client>
    <jaxws:properties>
<entry key="jaxb.additionalContextClasses">
...
</jaxws:client>

[1]is more details about the jaxws configuration.

Alternatively I think you can provide your jaxb.index file to honor extra classes.


[1]http://cxf.apache.org/docs/jax-ws-configuration.html

Freeman

On 2011-1-6, at 上午1:36, zahid wrote:


hello,

Im new to CXF and webservices in general. Can anybody explain to me how I
can add xsd bindings to the JaxWsClientProxy? Basicaly I have used the
wsdl2java tool to generate my bindings as defined in the WSDL for the
webservie I am connecting to. This is all good and I have a client that tries to call one of the webservice methods. This particular method takes an object as its payload which is defined in a seperate xsd and not in the
wsdl.

In order to generate the java code for these external objects - I use the
cxf-xjc-plugin and am able to generate the java code based n the xsd.
However when I try and pass an instance of my object to the webservice
method - I get

javax.xml.ws.soap.SOAPFaultException: Marshalling Error: class
com.test.SimpleObject nor any of its super class is known to this context.

Which makes sense because the JaxWsClientProxy is not aware of the external
bindings I suppose? THe problem is I am realy not sure how to make it
aware...

I tried the following in my pom:

<execution>
                       <id>generate-sources-webCAT-WSDL</id>
                       <phase>generate-sources</phase>
                       <configuration>

<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
                           <wsdlOptions>
                               <wsdlOption>

<wsdl>${basedir}/src/main/wsdl/ExternalWebService.wsdl</wsdl>
                                   <bindingFiles>
                                
<bindingFile>${basedir}/src/main/xsd/SimpleObject.xsd</bindingFile>
                                </bindingFiles>
                                   <extraargs>
                                       <extraarg>-client</extraarg>
                                   </extraargs>
                               </wsdlOption>
                           </wsdlOptions>
                       </configuration>
                       <goals>
                           <goal>wsdl2java</goal>
                       </goals>
                   </execution>

however this didnt work! cna somebody tell me how I defined an external
binding based on an xsd?
sorry if this is a newbie questoin - but hey that is what I am :)
Thx


--
View this message in context: 
http://cxf.547215.n5.nabble.com/wsdl2java-with-external-xsd-binding-help-tp3329178p3329178.html
Sent from the cxf-user mailing list archive at Nabble.com.


--
Freeman Fang

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

FuseSource: http://fusesource.com
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org

Reply via email to