Turns out that I also need a file called jaxb.index in the same package as my domain object. It's a plain text file stating the name of the jaxb binded pojo.
My problem now is how to use the "object" returned. I tried to just simply cast it, but that gives me a ClassCastException. I guess I have to unmarshall it... Anders Hammar wrote: > > Ok, putting them in the same package is not really the thing here but what > you need is to have everything in the same namespace (java package is used > as default namespace, but that's a separate matter). However, this is not > your problem right now as you can't build, but you need to address that > later on. You can check if you have a problem by examining the wsdl file > (from a jmx console) and check that there is a schema for your domain > object(s). > > Regarding your set up, you're lacking some stuff that I have in my code. > I'll post mine below and you can compare. (I think what you're missing is > the jsr181 annotations of your service pojo.) > > My set up is just to test the jsr181 component and not a real world > scenario. I post a xml message to a queue, which is picked up by a jms > binding which sends it to the "foo:jsr" service (where the echo endpoint > is used as specified in my in xml message). That service will then access > the "foo:jsrreceive" service. > > xbean.xml: > <?xml version="1.0" encoding="UTF-8"?> > <beans xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0" > xmlns:foo="http://c.b.a.se"> > > <classpath> > <location>.</location> > </classpath> > > <jsr181:endpoint service="foo:jsrreceive" annotations="jsr181" > typeMapping="jaxb2" pojoClass="se.a.b.c.DummyService" > style="wrapped" /> > > <jsr181:endpoint service="foo:jsr" annotations="jsr181" > typeMapping="jaxb2" pojoClass="se.a.b.c.DummyService2" > style="wrapped" /> > </beans> > > DummyObjekt.java: > package se.a.b.c; > > import javax.xml.bind.annotation.XmlType; > > @XmlType(name="DummyObjekt", namespace="http://c.b.a.se") > public class DummyObjekt { > private String namn; > private int alder; > > public DummyObjekt() {} > > public int getAlder() { return alder; } > public void setAlder(int alder) { this.alder = alder; } > > public String getNamn() { return namn; } > public void setNamn(String namn) { this.namn = namn; } > } > > DummyService.java: > package se.a.b.c; > > import javax.jbi.component.ComponentContext; > import javax.jws.WebService; > > @WebService(endpointInterface="se.a.b.c.ServiceInterface") > public class DummyService implements ServiceInterface { > > private ComponentContext context; > > public DummyService() { } > > public ComponentContext getContext() { return context; } > public void setContext(ComponentContext context) { this.context = > context; } > > public DummyObjekt getDummyObjekt(String namn) { > DummyObjekt obj = new DummyObjekt(); > obj.setNamn(namn); > obj.setAlder(19); > > return obj; > } > } > > ServiceInterface.java: > package se.a.b.c; > > import javax.jws.WebMethod; > import javax.jws.WebService; > > @WebService > public interface ServiceInterface { > > @WebMethod > public DummyObjekt getDummyObjekt(String namn); > } > > DummyService2.java: > package se.a.b.c; > > import javax.jbi.JBIException; > import javax.jbi.component.ComponentContext; > import javax.jws.WebService; > import javax.xml.namespace.QName; > > import org.apache.servicemix.client.ServiceMixClient; > import org.apache.servicemix.client.ServiceMixClientFacade; > import org.apache.servicemix.jbi.resolver.EndpointResolver; > > @WebService(endpointInterface="se.a.b.c.Service2Interface") > public class DummyService2 implements Service2Interface { > > private ComponentContext context; > > public DummyService2() { } > > public ComponentContext getContext() { return context; } > public void setContext(ComponentContext context) { this.context = > context; } > > public void echo(String input) { > try { > ServiceMixClient client = new > ServiceMixClientFacade(getContext()); > QName service = new QName("http://c.b.a.se", "jsrreceive"); > EndpointResolver resolver = > client.createResolverForService(service); > > String content = > "<getDummyObjekt><namn>"+input+"</namn></getDummyObjekt>"; > > Object obj = client.request(resolver, null, null, content); > /*...*/ > } catch (Exception e) { > /*...*/ > } > } > } > > Service2Interface.java: > package se.a.b.c; > > import javax.jws.Oneway; > import javax.jws.WebMethod; > import javax.jws.WebService; > > @WebService > public interface Service2Interface { > > @WebMethod > @Oneway > public void echo(String input); > } > > > Hope it helps, > /Anders > > > > moraleslos wrote: >> >> I think I'm running into the issue you described below. I searched the >> forums for something similar and also placed my service POJO in the same >> package as my domain POJOs to no avail. The error I'm getting is this: >> >> ################################ >> [INFO] Failed to generate jbi.xml >> >> Embedded error: Unable to generate service unit descriptor! >> The name "" is not legal for JDOM/XML namespaces: Namespace URIs must be >> non-null and non-empty Strings. >> ################################ >> >> >> Tracing the code looks like its coming from the generateWsdl() method in >> Jsr181Endpoint. I'm not sure what I'm missing in my xbean.xml or my >> jsr181 service so I'll provide the code below: >> >> ################################ >> My xbean.xml: >> >> <beans >> xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0" >> xmlns:foo="http://test.com/integration/servicemix"> >> >> <classpath> >> <location>.</location> >> </classpath> >> >> <jsr181:endpoint >> service="foo:xmlUnmarshaller" >> interfaceName="retrieveData" >> >> pojoClass="com.test.integration.servicemix.TestUnmarshallingService" >> typeMapping="jaxb2"/> >> >> </beans> >> >> >> and my JSR181 POJO: >> >> public class TestUnmarshallingService{ >> public void retrieveData( Document document ) { >> documentDAO.save( document ); >> } >> } >> >> ##################################### >> >> Thanks in advance. >> >> -los >> >> >> >> >> Anders Hammar wrote: >>> >>> >>> You probably want to read another thread here on the forum where a >>> problem with different namespaces for your service and your pojos is >>> described. As of now, your object model has to be in the same namespace >>> as your service or the generated schema will not include them. There is >>> also a Jira for this issue. >>> >>> >>> moraleslos wrote: >>>> >>>> I'm a bit confused. All I want to do is unmarshal data from an XML >>>> document that is coming from the NMR into my pojos... I thought that >>>> was what the typeMapping attribute was for. >>>> >>>> So if I'm understanding correctly, I'll need to create a Web service >>>> that will accept this XML document and then invoke another service that >>>> will use jaxb2 APIs to unmarshal the data? Again, I'm still fairly new >>>> to all of this jsr181 stuff. Thanks in advance. >>>> >>>> -los >>>> >>> >>> >> >> > > -- View this message in context: http://www.nabble.com/connecting-to-jsr-181-jaxb2-tf2523299s12049.html#a7396602 Sent from the ServiceMix - User mailing list archive at Nabble.com.
