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.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"

    <!-- wsdl:types encapsulates schema definitions of communication types;
    here using xsd -->
    <xsd:schema xmlns:xsd="" xmlns:ouaf="urn:oracle:ouaf" targetNamespace="urn:oracle:ouaf" elementFormDefault="unqualified">
    <xsd:element name="Fault">
    <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: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: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:simpleType name="date">
    <xsd:restriction base="xsd:token">
    <xsd:pattern value="[0-9]{4}-[0-1][0-9]-[0-3][0-9]"/>
    <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:simpleType name="money">
    <xsd:restriction base="xsd:decimal"/>

    <xsd:schema xmlns:xsd="" xmlns:ouaf="urn:oracle:ouaf" targetNamespace="" elementFormDefault="qualified">
    <xsd:import namespace="urn:oracle:ouaf"/>
    <xsd:element name="CM_PORTG3">
    <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: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:attribute name="faultStyle" type="xsd:string" fixed="wsdl" use="required"/>


    <!-- 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"/>

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

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

    <!-- 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:binding states a serialization protocol for this service -->
    <wsdl:binding name="CM_PORTG3SoapBinding"
    <!-- leverage off soap:binding document style @@@(no wsdl:foo pointing at
    the soap binding) -->
    <soap:binding style="document"

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

    <!-- again bind to SOAP? @@@ -->
    <soap:operation soapAction=""/>

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

    <!-- 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"

    <!-- give the binding a network address -->
    <soap:address location=""/>
  • #764595

    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.

    Blog :

  • #764661

    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 = "")]
    [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

    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

    Never lose hope..You never know what tomorrow will bring

  • Sign In to post your comments