Hi Anders,
Thanks for the reply... I retrofitted your example code into mine. I
finally got past the compilation step so that worked great. Now when I
deploy my jbi, I get this exception:
####################
11:36:49,293 | INFO | Thread-15 | DefaultFaultHandler |
re.handler.DefaultFaultHandler 39 | Fault occurred!
org.codehaus.xfire.fault.XFireFault: Invalid operation: document
at
org.codehaus.xfire.service.binding.WrappedBinding.readMessage(WrappedBinding.java:41)
at
org.codehaus.xfire.soap.handler.SoapBodyHandler.invoke(SoapBodyHandler.java:42)
at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at
org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:64)
at
org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
at
org.apache.servicemix.jsr181.Jsr181ExchangeProcessor.doProcess(Jsr181ExchangeProcessor.java:113)
at
org.apache.servicemix.jsr181.Jsr181ExchangeProcessor.process(Jsr181ExchangeProcessor.java:68)
at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:410)
at
org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:43)
at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:624)
at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:170)
at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:177)
at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:227)
at
org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown
Source)
at java.lang.Thread.run(Thread.java:619)
########################################
I used JConsole to probe my TestUnmarshallingService endpoint and everything
looks ok. The WSDL output looks like this:
########################################
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding"
xmlns:tns="http://test.com/integration/servicemix"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test.com/integration/servicemix">
<wsdl:types>
<xsd:schema attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="http://test.com/integration/servicemix"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="retrieveData">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:Document"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="retrieveDataResponse">
<xsd:complexType/>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="retrieveDataRequest">
<wsdl:part element="tns:retrieveData" name="parameters"/>
</wsdl:message>
<wsdl:message name="retrieveDataResponse">
<wsdl:part element="tns:retrieveDataResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="thomsonUnmarshallerPortType">
<wsdl:operation name="retrieveData">
<wsdl:input message="tns:retrieveDataRequest"
name="retrieveDataRequest"/>
<wsdl:output message="tns:retrieveDataResponse"
name="retrieveDataResponse"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
######################################
Notice that there is a referenced namespace for Document, but its not
defined anywhere in the WSDL. Not sure if this is ok or if something is
wrong with the WSDL generation (I'm not at all proficient with WSDL/Web
Services). My Document pojo looks like this:
######################################
@XmlRootElement(namespace="http://test.com/integration/servicemix")
public class Document {
// accessors to other XML subelements
}
######################################
Again, I packaged my domain objects in the same place where my services are
located. Any additional help would be appreciated. Thanks in advance!
-los
Anders Hammar wrote:
>
> 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#a7408084
Sent from the ServiceMix - User mailing list archive at Nabble.com.