Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
18 replies Latest Post - ‏2011-12-16T07:05:43Z by aryan_raj
aryan_raj
aryan_raj
67 Posts
ACCEPTED ANSWER

Pinned topic web services

‏2011-12-06T10:29:28Z |
Hi All,

I am new to wpf, can anybody post some tutorial/pdf link on how to use the web service builders ( how to invoke, how to consume etc.,). Any simple example will do.
Updated on 2011-12-16T07:05:43Z at 2011-12-16T07:05:43Z by aryan_raj
  • mburati
    mburati
    425 Posts
    ACCEPTED ANSWER

    Re: web services

    ‏2011-12-06T15:34:52Z  in response to aryan_raj
    Try searching the WEF/WPF help, this forum, the WPF Wiki and the WPF Best Practices forum for "Web Service" and you'll likely find quite a bit of info and questions/answers that'll likely prove helpful.

    The following similar thread question in the forum may help:
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14618595&#14618595

    In general:
    - Document/Listeral web services tend to be the most interoperable across vendors/products
    - The multi-vendor (including IBM) Web Service Interoperability Organization ( http://ws-i.org/ )specs banned RPC/Encoded for interop reaons many years ago, so I would avoid RPC/Encoded web services if possible.
    - Web Service MultiOperation builder does a lot more for you (adds service definition and service operation builders for you) and it's more efficient than Web Service Call, so I recommend using WS MultiOp over WS Call whenever possible.

    ..mb1
  • aryan_raj
    aryan_raj
    67 Posts
    ACCEPTED ANSWER

    Re: web services

    ‏2011-12-09T11:17:41Z  in response to aryan_raj
    Hi,

    WPF infocenter says that the Web Service Multiple Operations builder creates different objects, which contains variables -
    operation_name_arg1_input_name
    Schema typed input variables for each of the service call inputs.
    operation_name_reply
    This schema-typed variable that is to contain the IXml value of the service call result.
    My sample web service call is returning the output, but it is a xml output, so according to the infocenter, can I use the "operation_name_reply " variable to get the output value instead of xml output. If so, please suggest how to get the value otherwise how to get only the value instead of the xml.
    • mburati
      mburati
      425 Posts
      ACCEPTED ANSWER

      Re: web services

      ‏2011-12-09T15:17:09Z  in response to aryan_raj
      Most of the WEF runtime automates the generation and page automation runtime of the application based on well structured schema defined XML, so if you're passing the result of the web service back from the service provider to a consumer to be used with page automation, then it's best to leave it in the XML structure that page automation expects to be there.

      If you have some logic you need to do in the consumer or provider, then there might be a reason to pull it out of the XML, but please be sure that you really need to do that, so your app isn't doing more work than it needs to and missing things that WEF could be automating for you.

      If you could describe the use case (are you trying to do this in the provider or consumer, and for what use do you need that data in non-XML format?) it might help someone come up with a suggested means of meeting your use case.

      In general though, if you have an XML variable and you want to manipulate it or pull stuff out of it with code, you can use the WEF IXml API.
      Try starting with a "Method" builder first because it adds some commented out sample code for how to get variable values etc, read the javadoc for the IXml API and try it out, if this is what you really need. If your Method gets complex (more than a couple methods or more than a few lines of code in a Method builder, then consider moving that Method to a Java class and pulling that Java class in with a Linked Java Object builder call so that you can edit the Java method(s) with the full fledged Eclipse Java editor instead of in the method builder input window.

      I hope that helps,
      ..mb1
      • aryan_raj
        aryan_raj
        67 Posts
        ACCEPTED ANSWER

        Re: web services

        ‏2011-12-13T06:38:35Z  in response to mburati
        Sorry for the late reply, In my application, I want to get the value (only the value not the entire xml) from the web service output in the consumer and display it to the user.
        Is it mandatory that I need to use some builder to get the value from the web service output, can't I use the variables that are generated by the Web service multi-ops builder?
        • mburati
          mburati
          425 Posts
          ACCEPTED ANSWER

          Re: web services

          ‏2011-12-13T14:08:54Z  in response to aryan_raj
          That's typically what Web Experience Factory does for you, carries around the data between the provider and consumer in XML, but then (via page automation) displays the value for you (not the XML) in the consumer, via Data Page and higher level builders built on top of Data Page (like View and Form, DSUI ...).

          Have you tried using WS MultiOp to build a provider model for your web service, and then use Service Consumer and View and Form or Data Page to display the results of that operation to a consumer? If so, what happened when you tried that?

          Do you have an example of the XML and WSDL/Schema for this particular web service that you're calling that you could post here, along with which part(s) you need to display?

          ..mb1
          • aryan_raj
            aryan_raj
            67 Posts
            ACCEPTED ANSWER

            Re: web services

            ‏2011-12-13T16:01:04Z  in response to mburati
            I am using a sample web service, service provider is built using WS Multi Ops builder, I am invoking this on click of a button on the page, please refer snapshot, below is the endpoint,
            http://www.webservicex.net/ConvertTemperature.asmx

            Output - <:ConvertTempResponse xmlns="http://www.webserviceX.NET/"><:ConvertTempResult>150.8

            I want to extract only the output value, i.e, 150.8 not the entire xml output.
            • mburati
              mburati
              425 Posts
              ACCEPTED ANSWER

              Re: web services

              ‏2011-12-13T16:12:51Z  in response to aryan_raj
              I wouldn't expect the output shown in your screen shot. If you have a sample provider and consumer model (with no proprietary/confidential info or intellectual property) that exhibits the behavior that you could post, it could help someone spot what's going wrong more quickly and suggest what to change.

              ..mb1
              • aryan_raj
                aryan_raj
                67 Posts
                ACCEPTED ANSWER

                Re: web services

                ‏2011-12-14T15:44:03Z  in response to mburati
                PFA,

                Attachments

                • mburati
                  mburati
                  425 Posts
                  ACCEPTED ANSWER

                  Re: web services

                  ‏2011-12-14T17:08:52Z  in response to aryan_raj
                  Thanks for the simple sample. Your consumer model didn't appear to be using page automation to display the result, it was just calling the operation, which is why the only result you were getting was the internal one wrapped in XML so that it could be passed around and to page automation which needs to know the structure of the data it's receiving.

                  I deleted the "main" action list, imported page, button and variable in your consumer model and replaced those with a single View and Form (high level page automation builder that introspects a service operation and it's schema defined inputs and outputs and generates the pages, actions and controls for you) and your model now generates an input page to take the input temperature value and conversion from and to types, a button to submit it and a results page to show the numeric result, along with a back button to go back to the input page. Here's your model with that simple change, that should be able to be used with the same provider you had attached. I did not make any changes to the Web Service builder call, I just deleted those other builder calls and added View and Form.

                  I hope this helps,
                  ..mb1
                  • aryan_raj
                    aryan_raj
                    67 Posts
                    ACCEPTED ANSWER

                    Re: web services

                    ‏2011-12-15T06:55:18Z  in response to mburati
                    Thanks a lot, are these labels, input texts for the inputs created by the View & Form builder, how does it know these things
                    • mburati
                      mburati
                      425 Posts
                      ACCEPTED ANSWER

                      Re: web services

                      ‏2011-12-15T14:08:11Z  in response to aryan_raj
                      Look in the Schema object created in your webapp, in the Web Application view of the designer for your model, and you should see where the schema from the WSDL you imported defined the names of the input and output structures and the enumeration values for the conversion types.

                      That's where the initial labels for the inputs/outputs are created from.

                      Look down towards the bottom of the View and Form builder and you should see a builder input that allows you to specify a Java resource bundle name to use for specifying translatable values for the labels used by View and Form. Check out the help for the View and Form builder and search for "resource bundle" in the Web Experience Factory help to learn more about translation/localization support in Web Experience Factory.

                      ..mb1
                      • aryan_raj
                        aryan_raj
                        67 Posts
                        ACCEPTED ANSWER

                        Re: web services

                        ‏2011-12-15T15:37:35Z  in response to mburati
                        Thank you mb1, really helpful information. Can you please share articles/tutorials/samples to learn the View and Form builder in detail, looks interesting. And what are the other important (commonly used) page automation builders.
                        • mburati
                          mburati
                          425 Posts
                          ACCEPTED ANSWER

                          Re: web services

                          ‏2011-12-15T18:06:21Z  in response to aryan_raj
                          If you're new to Web Experience Factory, then the product wiki is the best place to start:
                          http://www-10.lotus.com/ldd/pfwiki.nsf

                          In particular, the learning roadmap directly off that main wiki page is where we typically suggest people start with reading about the product.
                          http://www-10.lotus.com/ldd/pfwiki.nsf/dx/learning-websphere-portlet-factory

                          The product documentation, with help for the page automation builders (Data Page, View and Form, Data Services User Interface etc) is also off that main wiki page. http://www-10.lotus.com/ldd/pfwiki.nsf/xpViewCategories.xsp?lookupName=WebSphere%20Portlet%20Factory%207.0.1%20Documentation

                          The tutorials that come with the product are also a good place to start.
                          http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Tutorial_Creating_a_database_application_wpf701

                          There are a couple of Web Experience Factory courses available that may also help.

                          Here's a link to the introductory videos available off the wiki page:
                          http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Web_Experience_Factory_Video_Gallery

                          And a set of application pattern wiki pages, on the WEF WIki:
                          http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Application_Patterns_with_Web_Experience_Factory

                          I hope that info helps,
                          ..mb1
                      • aryan_raj
                        aryan_raj
                        67 Posts
                        ACCEPTED ANSWER

                        Re: web services

                        ‏2011-12-15T15:57:04Z  in response to mburati
                        Hi mb1,

                        when I run it, it is showing the below message,

                        HTTP Status 404 - /FirstWS/factory/designer/preview_webapp.jsp
                        • mburati
                          mburati
                          425 Posts
                          ACCEPTED ANSWER

                          Re: web services

                          ‏2011-12-15T18:07:47Z  in response to aryan_raj
                          The JSP is the one used by the designer to run from designer. If you get an HTTP 404 (not found) on that, then it's likely your project isn't completely/successfully deployed to the appserver. Try publishing the application to the appserver (right click on the project and select Publish Application from the project menu.

                          I hope that helps,
                          ..mb1