Topic
21 replies Latest Post - ‏2011-11-08T22:30:50Z by SystemAdmin
Ed_Hansen
Ed_Hansen
28 Posts
ACCEPTED ANSWER

Pinned topic Configuring Operation Selector on JMS Binding for SCA Component for OSGi

‏2011-10-14T19:36:25Z |
I have created a JMS binding on an SCA component, which is wrapping a blueprint service implemented in OSGi. My intention is to have a one way service call, basically triggering an operation via XML dropped onto a queue.

My 'Wire Format' is JMS Text XML
My 'Operation selectors' is set up as JMS user property with a User property of 'operationSelector'
My 'Configure connection' is set up with a Destination and Activation Spec

I marshal my request object to XML using JAXB and add a user property to the message called operationSelector with a value corresponding to the operation to be invoked. I have tried several different values for the operation. The name of the operation from the blueprint.xml, the name of the operation's class, and the fully qualified name of the operation's class. None have worked.

When the message is received, I get an error saying "Can't find operation XXX". Where XXX is the value that I've specified in the user property. So I know that SCA is successfully processing the message from the queue, but it can't resolve the operation name.

So what is that operation name supposed to be? I have yet to find a real description in any IBM docs I've found.
Updated on 2011-11-08T22:30:50Z at 2011-11-08T22:30:50Z by SystemAdmin
  • Ed_Hansen
    Ed_Hansen
    28 Posts
    ACCEPTED ANSWER

    Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

    ‏2011-10-15T05:22:55Z  in response to Ed_Hansen
    Found at least part of my answer. The operation name must match the name of the operation in the interface that the service implements. Sometimes the toughest questions are those with the most obvious answer.

    Now I just need to figure out why the payload of the message I'm sending is not being unmarshalled into the request object for my operation.
    • SystemAdmin
      SystemAdmin
      126 Posts
      ACCEPTED ANSWER

      Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

      ‏2011-10-17T15:02:01Z  in response to Ed_Hansen
      Hi Ed,

      Glad you were able to resolve your issue with the operation selector.

      If I had to guess what problem you might be having figuring out the unmarshalling, I'd guess you might be getting confused by the wrapper that's typically required in the payload when using the text XML wire format.
      If you read our article on JMS wire formats, you'll see these sample snippets in section Examples of TextMessage messages using JAXB

      The Java method:

      
      
      
      package com.ibm.test.soa.sca; 
      
      public String getGreetings(String name);
      


      results in a payload like:

      
      <ns2:getGreetings xmlns:ns2=
      "http://sca.soa.test.ibm.com/"> <arg0>Mike</arg0> </ns2:getGreetings>
      


      with a Java 'name' parameter value of "Mike", that is.

      There is an operation-level <ns2:getGreetings> "wrapper" element, wrapping the serialized parameter value.

      Actually the presence of the wrapper is the main difference between the text XML wireformat and the default wire format, but before saying any more, let me wait and see if that helps you at all, though I could explain a bit more if you're still having trouble.

      Regards,
      Scott Kurz
      • Ed_Hansen
        Ed_Hansen
        28 Posts
        ACCEPTED ANSWER

        Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

        ‏2011-10-17T23:59:21Z  in response to SystemAdmin
        Hi Scott,

        Thanks for your help. Using your example, I was able to successfully invoke a simple pojo method via a JMS message.

        But I realized that it's a little different than what we actually want to do. We are exposing a service via blueprint in OSGi. We have successfully added a SOAP binding to our SCA component which allows us to invoke the exposed operation on the OSGi service. What we're trying to do now is to add a JMS binding to the component that will allow us to invoke the same operation.

        So instead of invoking a pojo, we are trynig to invoke an OSGi service operation defined in blueprint.

        Is that possible? Or for the JMS binding would we have to bypass blueprint and invoke the operation's java implementation directly?

        Ed
        • Ed_Hansen
          Ed_Hansen
          28 Posts
          ACCEPTED ANSWER

          Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

          ‏2011-10-18T00:20:08Z  in response to Ed_Hansen
          BTW - when creating our SCA component, we had set the implementation to OSGi application.
          • SystemAdmin
            SystemAdmin
            126 Posts
            ACCEPTED ANSWER

            Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

            ‏2011-10-18T13:55:51Z  in response to Ed_Hansen
            Ed,

            So by saying,

            Using your example, I was able to successfully invoke a simple pojo method via a JMS message.

            I think what you're saying is that you were successfully able to invoke over a JMS binding a component with Java implementation (<implementation.java>), and you're wondering how to do something similar with OSGi implementation (<implementation.osgiapp>).

            The good news is, the JMS message would look exactly the same !

            That is, for a Java impl and an OSGi impl with the same interface, the JMS message needed to invoke over a JMS binding would be identical. This points to a key feature of SCA, services are described abstractly by interfaces independently of implementation type.

            Now, there are more "moving parts" involved in implementation.osgiapp,

            See our InfoCenter article for details.

            One area that's a bit tricky you'll see documented in this sub-article
            here is explained in section Interface definition. The exact syntax used to explicitly specify an interface (or not used if you implicitly specify the interface) can have a packaging impact, in that you have to drag in the interface file into the SCA asset (JAR).

            But these details aside, the leap you've made to understand the details of the wireformat is all that is needed to invoke the service with either implementation type.

            Please let us know how this works out for you.

            Regards,
            Scott Kurz
            • Ed_Hansen
              Ed_Hansen
              28 Posts
              ACCEPTED ANSWER

              Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

              ‏2011-10-18T18:28:32Z  in response to SystemAdmin
              Thanks Scott,

              To be more clear - my test consisted of an SCA component with an OSGi implementation. The service interface contained one method with no arguments and no return value - like the example you referenced. In this case, the call succeeded - which was a great step forward!

              Now I have enhanced the service method to take a complex object as an argument. I've followed another snippet from the example you referenced, but can't seem to get it to work. The object makes it to the service method, but the values in the object are null.

              Here is the service interface:
              package test;
              import javax.jws.Oneway;
              public interface MyTestInterface {
              @Oneway
              public void showName(FullName fullName);
              }

              Here is the class definition for the implementation of the service interface:
              package test;
              public class MyTest implements MyTestInterface {
              public void showName(FullName fullName) {
              System.out.println("In showName - name: " + fullName.firstName + " " + fullName.lastName);
              }
              }

              Here is the class definition for the object I'm passing:
              package test;
              import javax.xml.bind.annotation.XmlElement;
              public class FullName {
              @XmlElement
              public String firstName;
              @XmlElement
              public String lastName;
              }

              Here is the XML I'm putting on the queue:
              <ns2:showName xmlns:ns2="http://test">
              <arg0>
              <ns2:firstName>Bob</ns2:firstName>
              <ns2:lastName>Jones</ns2:lastName>
              </arg0>
              </ns2:showName>

              My guess is that I'm missing something in the class definition of the object being passed. Is there another annotation necessary?
              • SystemAdmin
                SystemAdmin
                126 Posts
                ACCEPTED ANSWER

                Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                ‏2011-10-19T14:31:22Z  in response to Ed_Hansen
                Hi Ed,

                I have a guess for this one as well, which is that you making the subtle mistake of incorrectly qualifying the child elements contrary to the elementFormDefault setting.

                So instead of:

                
                <ns2:showName xmlns:ns2=
                "http://test"> <arg0> <ns2:firstName>Bob</ns2:firstName> <ns2:lastName>Jones</ns2:lastName> </arg0> </ns2:showName>
                


                Try:

                
                <ns2:showName xmlns:ns2=
                "http://test"> <arg0> <firstName>Bob</firstName> <lastName>Jones</lastName> </arg0> </ns2:showName>
                


                The JAXB implementation's unmarshaller is very strict in this regard, in that it won't match up the qualified child with the JAXB property corresponding to the unqualified child. But since the unmarshaller doesn't do schema validation, rather than blowing up with an exception it simply leaves those properties set to default values (null) in the Java object built by unmarshalling.

                The default value for elementFormDefault is "unqualified", so if you didn't specify one in your schema that's what you'd be using.

                In case you're not too familiar with elementFormDefault, here is a good article on the relation between elementFormDefault in schema definitions and XML "instance" documents.

                Hope that helps,
                Scott
                • Ed_Hansen
                  Ed_Hansen
                  28 Posts
                  ACCEPTED ANSWER

                  Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                  ‏2011-10-20T15:45:06Z  in response to SystemAdmin
                  Hi Scott,

                  I'm afraid this still didn't work. I'm still getting null values for the fields in the object.

                  Ed
                  • SystemAdmin
                    SystemAdmin
                    126 Posts
                    ACCEPTED ANSWER

                    Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                    ‏2011-10-20T17:50:13Z  in response to Ed_Hansen
                    Ed,

                    I still think your problem is that your payload isn't precisely schema valid, maybe for some other reason.

                    Can you try using a tool to confirm?

                    If you want to attach your schema and a sample payload I could take a look for you.

                    Scott
                    • Ed_Hansen
                      Ed_Hansen
                      28 Posts
                      ACCEPTED ANSWER

                      Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                      ‏2011-10-20T18:02:00Z  in response to SystemAdmin
                      Thanks Scott,

                      Here is the schema:

                      <schema targetNamespace="http://test/"
                      elementFormDefault="qualified"
                      xmlns="http://www.w3.org/2001/XMLSchema">
                      <complexType name="NewFullName">
                      <sequence>
                      <element name="firstName" type="string"/>
                      <element name="lastName" type="string"/>
                      </sequence>
                      </complexType>
                      </schema>
                      And here is the latest payload I tried:
                      <ns2:showName xmlns:ns2="http://test/">
                      <arg0>
                      <firstName>Bob</firstName>
                      <lastName>Jones</lastName>
                      </arg0>
                      </ns2:showName>
                      • SystemAdmin
                        SystemAdmin
                        126 Posts
                        ACCEPTED ANSWER

                        Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                        ‏2011-10-20T18:47:52Z  in response to Ed_Hansen
                        Ed,

                        I think just a minor tweak is needed.

                        I'm guessing you don't actually have the "showName" element defined in a WSDL/XSD, but rather are having the runtime will generate this wrapper-level schema element for you.

                        Assuming your Java interface is defined in package 'test', then the correct payload would be:

                        <ns2:showName xmlns:ns2="http://test/">
                        <arg0>
                        <ns2:firstName>Bob</ns2:firstName>
                        <ns2:lastName>Jones</ns2:lastName>
                        </arg0>
                        </ns2:showName>

                        That's because the <ns2:showName> element is generated with default elementFormDefault="unqualified".

                        I realize this does get complicated. It does get simpler in a sense if a WSDL/XSD is created upfront as you no longer have to worry about runtime-generated schema constructs, and this is one reason we recommend top-down, starting-from-WSDL development in general.

                        Give that a try and if that doesn't work maybe you could send your entire application (since it appears to be just a simple test app).

                        Scott
                        • Ed_Hansen
                          Ed_Hansen
                          28 Posts
                          ACCEPTED ANSWER

                          Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                          ‏2011-10-20T23:58:32Z  in response to SystemAdmin
                          Hi Scott,

                          Unfortunately, that's what we tried a few posts back.

                          I've attached an archive containing the test projects.

                          Thanks again for your help Scott.

                          Ed
                          • SystemAdmin
                            SystemAdmin
                            126 Posts
                            ACCEPTED ANSWER

                            Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                            ‏2011-10-21T17:24:40Z  in response to Ed_Hansen
                            Ed,

                            You're right. Sorry for missing the fact we'd already tried my last suggestion.

                            I could probably try deploying this real quick, though I won't be able to get to it today.

                            In the meantime let me mention one quirk of your test app here. In using package 'test' to define your interface, you are having the runtime map the generated schema defs (for the wrapper) to the same targetNamespace, {http://test}, that you've defined your FullName type within.

                            JAXB can be tricky when doing this sort of thing..

                            You might want to try making a small change and moving your Java interface into some other package, (e.g. test.intf), to see if this resolves the problem.

                            Your payload would then look something like:

                            
                            <ns1:showName xmlns:ns1=
                            "http:/intf.test" xmlns:ns2=
                            "http://test/"> <arg0> <ns2:firstName>Bob</ns2:firstName> <ns2:lastName>Jones</ns2:lastName> </arg0> </ns1:showName>
                            


                            Scott
                            • SystemAdmin
                              SystemAdmin
                              126 Posts
                              ACCEPTED ANSWER

                              Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                              ‏2011-10-25T17:18:54Z  in response to SystemAdmin
                              Ed,

                              I think I see your problem now.

                              The payload should be like:

                              
                              <ns1:showName xmlns:ns1=
                              "http://test/" xmlns:ns2=
                              "http://test"> <arg0> <ns2:firstName>Bob</ns2:firstName> <ns2:lastName>Jones</ns2:lastName> </arg0> </ns1:showName>
                              


                              There's an extra "/" at the end of the wrapper targetNamespace.

                              So, rather than an issue with the generated wrapper and XSD-defined definitions colliding in the same targetNamespace, we actually have different targetNamespace(s) though we didn't adjust the payload to reflect this.

                              How was I able to determine this?

                              By adding a <binding.ws> to the service and leveraging our ?wsdl support for the Web Service binding.

                              Point the browser at:
                              http://host:port/<component>/<service>?wsdl
                              in your case at:
                              http://host:port/TestComponent/TestServiceExport?wsdl

                              It is a bit indirect to have to add an extra binding to see the generated WSDL/XSD service description in the bottom-up case, but since we lack an implementation of an equivalent function for other bindings with XML wireformats, (e.g. <binding.sca> and <binding.jms>), it's the best solution today.

                              Of course, the complexity here might lead you to consider using a top-down approach starting with a WSDL/XSD which in most cases is ultimately a better way to go.

                              Hope that helps,
                              Scott
                              • Ed_Hansen
                                Ed_Hansen
                                28 Posts
                                ACCEPTED ANSWER

                                Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                                ‏2011-10-27T17:41:03Z  in response to SystemAdmin
                                Hi Scott,

                                I've got it all sorted out now. What really helped was your suggestion of looking at the generated WSDL, and also understanding the package-info file.

                                Thanks for all your help - I really appreciate it.

                                BTW - we have decided to go with a more top down approach, starting with schemas for our model objects.
                                • SystemAdmin
                                  SystemAdmin
                                  126 Posts
                                  ACCEPTED ANSWER

                                  Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                                  ‏2011-10-27T20:17:15Z  in response to Ed_Hansen
                                  Ed,

                                  Glad that helped! Next time I'll think to suggest the ?wsdl idea earlier...

                                  Regards,
                                  Scott
                                  • Ed_Hansen
                                    Ed_Hansen
                                    28 Posts
                                    ACCEPTED ANSWER

                                    Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                                    ‏2011-11-04T04:28:23Z  in response to SystemAdmin
                                    Hi Scott,

                                    I'm now working on the other side - trying to add a reference with a JMS binding to a component to invoke a service with a JMS binding on another component (the one I just got working). I've run into some difficulties - which I'm leaning toward thinking are due to missing configuration on the reference's binding, and am wondering if you can point me to any examples. I've done quite a bit of searching on the web and can't seem to find any.

                                    Thanks
                                    • Ed_Hansen
                                      Ed_Hansen
                                      28 Posts
                                      ACCEPTED ANSWER

                                      Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                                      ‏2011-11-04T16:58:20Z  in response to Ed_Hansen
                                      I found samples for SCA (including JMS) in WAS7 under app_server_root\samples, but they don't exist in WAS8.
                                      • SystemAdmin
                                        SystemAdmin
                                        126 Posts
                                        ACCEPTED ANSWER

                                        Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                                        ‏2011-11-04T19:21:08Z  in response to Ed_Hansen
                                        Ed,

                                        You'll find the V8 SCA samples here.

                                        And here is the top-level InfoCenter article on the JMS binding on the V7 SCA Feature Pack. I can't think of any substantial difference from V7 to V8.

                                        Scott
                                        • Ed_Hansen
                                          Ed_Hansen
                                          28 Posts
                                          ACCEPTED ANSWER

                                          Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                                          ‏2011-11-08T00:08:19Z  in response to SystemAdmin
                                          Hi Scott,

                                          Once I got the two-way one-way app working, I created an OSGi version.

                                          Wondering if that would be of any use to others.

                                          Ed
                                          • SystemAdmin
                                            SystemAdmin
                                            126 Posts
                                            ACCEPTED ANSWER

                                            Re: Configuring Operation Selector on JMS Binding for SCA Component for OSGi

                                            ‏2011-11-08T22:30:50Z  in response to Ed_Hansen
                                            Ed,

                                            If you're willing to post a sample app here on the forum for others to see and learn from, well, that could only be a good thing for future readers of this thread !

                                            So thank you.

                                            Let me just make a quick link to the forum terms and conditions as a reminder regarding copyrights, disclaimers and that sort of thing.

                                            Glad to have helped you make progress.

                                            Scott