Please disable your adblock and script blockers to view this page

Search this blog

Thursday, 14 January 2016

Consuming a SOAP Web Service quickly using Web Service Data Control (WSDL) in ADF

Creating and Consuming Web Servie is an important part development cycle . In earlier posts i have described about creating SOAP/REST Web Service
Create REST Web Service with Application Module declaratively in ADF 12.2.1
Create SOAP Web Service with Application Module quickly in ADF 12.2.1

Now this post is about consuming a SOAP Web Service. A very simple way to consume Web Service is to create Web Service Data Control (WSDL) for external Web Service URL
Here i am using a Country-Currency Web Service (http://www.webservicex.net/country.asmx) to create WSDL


  • Create a Fusion Web Application with default Model and ViewController project

  • Right click on Model project , Select New--> From Gallery--> Business Tier--> Web Services and select Web Service Data Control SOAP/REST 

  • It opens WSDL creation wizard , First Step is to provide Web Service Name and URL


  • Click on next and in second screen select the methods to expose in Data Control that will be further used by application


  • In third step we can set return type of Web Service response , there are two options -XML and CSV. Leave it as default XML


  • Click on Finish button to generate DataControl.dcx (It is created when DataControl is registered on Business Service not on ADF Business Components) and WSDL document



  • Creation of WSDL is done now create a page in view controller project and expand DataControls menu , there we will see a data control created for CountryWebServices 


  • Drag and drop GetCountries operation on page as a button and expand this operation and drop String as output text formatted to show response of webservice



  • In same manner drop another method as parameter form as it has one input parameter that takes country name as input and shows it's currency as output.
    See page source code-


  • <af:panelGroupLayout id="pgl1" layout="horizontal" valign="top">
                                <af:panelFormLayout id="pfl2" inlineStyle="width:600px;">
                                    <af:button actionListener="#{bindings.GetCountries.execute}" text="GetCountries"
                                               disabled="#{!bindings.GetCountries.enabled}" id="b1"/>
                                    <af:outputFormatted value="#{bindings.Return.inputValue}" id="of2"
                                                        partialTriggers="b1" inlineStyle="width:500px;color:blue;"/>
                                </af:panelFormLayout>
                                <af:panelFormLayout id="pfl1" inlineStyle="width:600px;">
                                    <af:inputText value="#{bindings.CountryName.inputValue}"
                                                  label="#{bindings.CountryName.hints.label}"
                                                  required="#{bindings.CountryName.hints.mandatory}"
                                                  columns="#{bindings.CountryName.hints.displayWidth}"
                                                  maximumLength="#{bindings.CountryName.hints.precision}"
                                                  shortDesc="#{bindings.CountryName.hints.tooltip}" id="it1">
                                        <f:validator binding="#{bindings.CountryName.validator}"/>
                                    </af:inputText>
                                    <af:button actionListener="#{bindings.GetCurrencyByCountry.execute}"
                                               text="GetCurrencyByCountry"
                                               disabled="#{!bindings.GetCurrencyByCountry.enabled}" id="b2"/>
                                    <af:outputFormatted value="#{bindings.Return1.inputValue}" id="of1"
                                                        partialTriggers="b2" inlineStyle="color:maroon;"/>
                                </af:panelFormLayout>
                            </af:panelGroupLayout>
    

  • Now run and check application




All done :) Sample ADF Application- Download
Cheers :) Happy Learning

4 comments :

  1. Hi Ashish,

    I have created a Web Service and I tested it so it's giving response. But the moment I tried to consume in main application where I've accessed it's method interface from Data control it's showing the error 404 response not found from the WebService URL which I have provided. So, please help me getting this sorted out

    ReplyDelete
    Replies
    1. Hi Pruthiviraj

      Is it a REST or SOAP web service ?
      You need to provide some more detail , I suggest you to post this problem on OTN fourm with sufficient detail

      Ashish

      Delete
    2. Hi Ashish,
      Thank you for this awesome blog!
      I have to pass Html header param with basic authentication username and password. I followed the above blog and also added the httpheadermap in the managed bean class and I could successfully test it in the integration WLS but when I deployed the application to the UAT Weblogic server, I am getting the "
      Client received SOAP Fault from server : Credential Authentication Failed" error. How to pass the httpheadermap similar to httpheadermap.put("Authorization", "Basic YXBpbWFyczpJVFNtYXJzMTIzIQ==")

      Delete
  2. How to handle the fault like country name is not valid ??

    ReplyDelete