You must Sign In to post a response.
  • Category: Webservices

    How to call invoke webservice method Using WSDL file as refernce ?

    I am not able to invoke the Web service Method using WSDL web reffernce.

    Step i Follow to invoke the webservice method

    1. Add Web refernce of WSDL file. (It generates the refernce method )
    2. create instance of service.
    3. assign parameter to service method.
    I am not able to invoke the service.

    Sample c# code

    CM_PORTG3_Ref.CM_PORTG3 _CM_PORTG3 = new CM_PORTG3_Ref.CM_PORTG3();
    _CM_PORTG3.startdate = "1-Aug-2015";
    _CM_PORTG3.enddate = "31-Aug-2015";
    _CM_PORTG3.aid = "Agent1";

    CM_PORTG3_Ref.CM_PORTG3Service _CM_PORTG3Service = new CM_PORTG3_Ref.CM_PORTG3Service();



    ////Smaple WSDl file format

    <?xml version="1.0"?>
    <!-- root element wsdl:definitions defines set of related services -->
    <wsdl:definitions name="CM_PORTG3"
    targetNamespace="http://ouaf.oracle.com/spl/XAIXapp/xaiserver/CM_PORTG3"
    xmlns:xai="http://ouaf.oracle.com/spl/XAIXapp/xaiserver/CM_PORTG3"
    xmlns:xaixsd="http://ouaf.oracle.com/spl/XAIXapp/xaiserver/CM_PORTG3"
    xmlns:schemans1="http://oracle.com/CM_PORTG3.xsd"
    xmlns:schemans2="http://oracle.com/CM_PORTG3.xsd"
    xmlns:ouaf="urn:oracle:ouaf"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

    <!-- wsdl:types encapsulates schema definitions of communication types;
    here using xsd -->
    <wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ouaf="urn:oracle:ouaf" targetNamespace="urn:oracle:ouaf" elementFormDefault="unqualified">
    <xsd:element name="Fault">
    <xsd:complexType>
    <xsd:all>
    <xsd:element name="ResponseStatus" type="xsd:string"/>
    <xsd:element name="ResponseCode" type="xsd:int"/>
    <xsd:element name="ResponseText" type="xsd:string"/>
    <xsd:element name="ResponseData" minOccurs="0">
    <xsd:complexType>
    <xsd:attribute name="parm1" type="xsd:string"/>
    <xsd:attribute name="parm2" type="xsd:string"/>
    <xsd:attribute name="parm3" type="xsd:string"/>
    <xsd:attribute name="parm4" type="xsd:string"/>
    <xsd:attribute name="parm5" type="xsd:string"/>
    <xsd:attribute name="parm6" type="xsd:string"/>
    <xsd:attribute name="parm7" type="xsd:string"/>
    <xsd:attribute name="parm8" type="xsd:string"/>
    <xsd:attribute name="parm9" type="xsd:string"/>
    <xsd:attribute name="text" type="xsd:string"/>
    <xsd:attribute name="category" type="xsd:string"/>
    <xsd:attribute name="numParm" type="xsd:int"/>
    <xsd:attribute name="number" type="xsd:int"/>
    </xsd:complexType>
    </xsd:element>
    </xsd:all>
    </xsd:complexType>
    </xsd:element>
    <xsd:simpleType name="dateTime">
    <xsd:restriction base="xsd:token">
    <xsd:pattern value="[0-9]{4}-[0-1][0-9]-[0-3][0-9]-[0-2][0-9]:[0-6][0-9]:[0-6][0-9]"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="date">
    <xsd:restriction base="xsd:token">
    <xsd:pattern value="[0-9]{4}-[0-1][0-9]-[0-3][0-9]"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="time">
    <xsd:restriction base="xsd:token">
    <xsd:pattern value="[0-2][0-9]:[0-6][0-9]:[0-6][0-9]"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="money">
    <xsd:restriction base="xsd:decimal"/>
    </xsd:simpleType>
    </xsd:schema>

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ouaf="urn:oracle:ouaf" targetNamespace="http://oracle.com/CM_PORTG3.xsd" elementFormDefault="qualified">
    <xsd:import namespace="urn:oracle:ouaf"/>
    <xsd:element name="CM_PORTG3">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="zone" type="xsd:string" minOccurs="0" default="CM_PORTG3"/>
    <xsd:element name="startdate" type="xsd:string" minOccurs="0"/>
    <xsd:element name="enddate" type="xsd:string" minOccurs="0"/>
    <xsd:element name="aid" type="xsd:string" minOccurs="0"/>
    <xsd:element name="rowCount" type="xsd:decimal" minOccurs="0"/>
    <xsd:element name="results" minOccurs="0" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="total1" type="xsd:string" minOccurs="0"/>
    <xsd:element name="casecd" type="xsd:string" minOccurs="0"/>
    <xsd:element name="aid" type="xsd:string" minOccurs="0"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    <xsd:attribute name="faultStyle" type="xsd:string" fixed="wsdl" use="required"/>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>

    </wsdl:types>

    <!-- wsdl:message elements describe potential transactions -->

    <!-- request CM_PORTG3Request is of type CM_PORTG3 -->
    <wsdl:message name="CM_PORTG3Request">
    <wsdl:part name="body" element="schemans1:CM_PORTG3"/>
    </wsdl:message>

    <!-- response CM_PORTG3Response is of type CM_PORTG3Response -->
    <wsdl:message name="CM_PORTG3Response">
    <wsdl:part name="body" element="schemans2:CM_PORTG3"/>
    </wsdl:message>

    <!-- fault CM_PORTG3Fault is of type CM_PORTG3Fault -->
    <wsdl:message name="CM_PORTG3Fault">
    <wsdl:part name="fault" element="ouaf:Fault"/>
    </wsdl:message>

    <!-- wsdl:portType describes messages in an operation -->
    <wsdl:portType name="CM_PORTG3PortType">
    <!-- the value of wsdl:operation eludes me -->
    <wsdl:operation name="CM_PORTG3">
    <wsdl:input message="xai:CM_PORTG3Request"/>
    <wsdl:output message="xai:CM_PORTG3Response"/>
    <wsdl:fault name="fault" message="xai:CM_PORTG3Fault"/>
    </wsdl:operation>
    </wsdl:portType>

    <!-- wsdl:binding states a serialization protocol for this service -->
    <wsdl:binding name="CM_PORTG3SoapBinding"
    type="xai:CM_PORTG3PortType">
    <!-- leverage off soap:binding document style @@@(no wsdl:foo pointing at
    the soap binding) -->
    <soap:binding style="document"
    transport="http://schemas.xmlsoap.org/soap/http"/>

    <!-- semi-opaque container of network transport details classed by
    soap:binding above @@@ -->
    <wsdl:operation name="CM_PORTG3">

    <!-- again bind to SOAP? @@@ -->
    <soap:operation soapAction="http://ouaf.oracle.com/spl/XAIXapp/xaiserver/CM_PORTG3"/>

    <!-- furthur specify that the messages in the wsdl:operation
    "CM_PORTG3" use SOAP? @@@ -->
    <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    <wsdl:fault name="fault">
    <soap:fault name="fault" use="literal"/>
    </wsdl:fault>
    </wsdl:operation>
    </wsdl:binding>

    <!-- wsdl:service names a new service "CM_PORTG3Service" -->
    <wsdl:service name="CM_PORTG3Service">
    <wsdl:documentation>CM_PORTG3 version 2: Case Count against status-User ID for Genesys</wsdl:documentation>

    <!-- connect it to the binding "CM_PORTG3SoapBinding" above -->
    <wsdl:port name="CM_PORTG3Port"
    binding="xai:CM_PORTG3SoapBinding">

    <!-- give the binding a network address -->
    <soap:address location="http://192.168.1.50:4500/spl/XAIApp/xaiserver/CM_PORTG3"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>
  • #764595
    Hi,

    To invoke webservice methods in your project, you need to include the webservice by adding service reference by passing URL of that. Once your serivce is included then create your own methods and then deploy it and then get the dll of that service and then add it to your project, then obviously you will get the methods which you created earlier, if you done everything perfect.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #764661
    hi,


    Refer below example:
    web service, we can access across internet.
    Which will contain web methods.We can use in our application as Class library. We have to call the web methods which resides in internet server.
    What we to do is, we have to add reference to webservice URL, then we can call those web methods.

    For Ex:
    Here i am writing get_factorial, HelloWorld methods inside the web service.

    And want to use in our application like On button click if you want to get the factorial of a number inside ur textbox using Web service...

    Here is WebService.cs

    using System;
    using System.Collections;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Linq;

    /// <summary>
    /// Summary description for WebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class WebService : System.Web.Services.WebService {

    public WebService () {

    //Uncomment the following line if using designed components
    //InitializeComponent();
    }

    [WebMethod]
    public string HelloWorld() {
    return "Hello World";
    }
    public int get_factorial(int a)
    {
    int fact = 1;
    for (int i = 1; i <= a; i++)
    {
    fact = fact * i;
    }
    return fact;
    }

    }

    On button click if you want to get the factorial of a number inside ur textbox using Web service...

    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;


    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    WebService testWebService = new WebService();
    int sample = testWebService.get_factorial(int.Parse(TextBox1.Text));
    TextBox1.Text = testWebService.get_factorial(int.Parse(TextBox1.Text)).ToString();


    string hello = testWebService.HelloWorld();
    }
    }


    Hope this will help you

    Regards,
    SonyShiva
    Never lose hope..You never know what tomorrow will bring


  • Sign In to post your comments