Binding a WSDL file to a web service class

Discussion in 'ASP .Net Web Services' started by Youcef, Aug 20, 2004.

  1. Youcef

    Youcef Guest

    I started developing an ASP.NET web service by explicitly
    designing the WSDL and separating the data type definitions into XSD
    files. I followed the steps described in the following MSDN article to
    enlist the help of VS.NET in doing this through the use of separate
    namespaces and the [WebServiceBindingAttribute]. See :

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service08202002.asp

    But I found that I couldn't pass an XML Schema ComplexType (e.g. an
    address class) as an input parameter to one of the methods of the web
    service !! If I pass a simple type or I move the same complextype
    parameter as a return value from the method, VS.NET 2003 generates the
    right stuff and the method is listed among the available methods for
    the web service . I spent 2 days checking and re-checking everything
    to no avail. This must be a bug, but I couldn't find it mentioned
    anywhere. Has anybody tried this ?
     
    Youcef, Aug 20, 2004
    #1
    1. Advertising

  2. Youcef

    Youcef Guest

    By the way, below is the simplified example of my web service and the
    complextype I'm trying to pass in as parameter. The WSDL and XSD files were
    generated and fixed as described in the MSDN article:

    [WebServiceAttribute(Namespace="http://acme.com/2004/SampleService")]
    [WebServiceBindingAttribute("SampleBinding",
    "http://acme.com/2004/SampleService/SampleBinding",
    "http://localhost/SampleService/Service1.wsdl")]

    public class UserService : System.Web.Services.WebService
    {
    public UserService()
    {
    //CODEGEN: This call is required by the ASP.NET Web Services Designer
    InitializeComponent();
    }

    #region Component Designer generated code

    //Required by the Web Services Designer
    private IContainer components = null;

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if(disposing && components != null)
    {
    components.Dispose();
    }

    base.Dispose(disposing);
    }

    #endregion

    // WEB SERVICE EXAMPLE

    [WebMethod]
    [SoapDocumentMethodAttribute(Binding="SampleBinding")]
    public void StoreUser(User userData)
    {
    }
    }


    and here is the definition of the input parameter of type User ( a
    complextype):

    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://acme.com/2004/SampleService/DataTypes")]
    public class User
    {
    public string firstname;
    public string lastname;
    }






    "Youcef" wrote:

    > I started developing an ASP.NET web service by explicitly
    > designing the WSDL and separating the data type definitions into XSD
    > files. I followed the steps described in the following MSDN article to
    > enlist the help of VS.NET in doing this through the use of separate
    > namespaces and the [WebServiceBindingAttribute]. See :
    >
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service08202002.asp
    >
    > But I found that I couldn't pass an XML Schema ComplexType (e.g. an
    > address class) as an input parameter to one of the methods of the web
    > service !! If I pass a simple type or I move the same complextype
    > parameter as a return value from the method, VS.NET 2003 generates the
    > right stuff and the method is listed among the available methods for
    > the web service . I spent 2 days checking and re-checking everything
    > to no avail. This must be a bug, but I couldn't find it mentioned
    > anywhere. Has anybody tried this ?
    >
     
    Youcef, Aug 20, 2004
    #2
    1. Advertising

  3. instead of a named complexType, can you specify the input datatype as an
    element?


    "Youcef" <> wrote in message
    news:...
    > By the way, below is the simplified example of my web service and the
    > complextype I'm trying to pass in as parameter. The WSDL and XSD files

    were
    > generated and fixed as described in the MSDN article:
    >
    > [WebServiceAttribute(Namespace="http://acme.com/2004/SampleService")]
    > [WebServiceBindingAttribute("SampleBinding",
    > "http://acme.com/2004/SampleService/SampleBinding",
    > "http://localhost/SampleService/Service1.wsdl")]
    >
    > public class UserService : System.Web.Services.WebService
    > {
    > public UserService()
    > {
    > //CODEGEN: This call is required by the ASP.NET Web Services Designer
    > InitializeComponent();
    > }
    >
    > #region Component Designer generated code
    >
    > //Required by the Web Services Designer
    > private IContainer components = null;
    >
    > /// <summary>
    > /// Required method for Designer support - do not modify
    > /// the contents of this method with the code editor.
    > /// </summary>
    > private void InitializeComponent()
    > {
    > }
    >
    > /// <summary>
    > /// Clean up any resources being used.
    > /// </summary>
    > protected override void Dispose( bool disposing )
    > {
    > if(disposing && components != null)
    > {
    > components.Dispose();
    > }
    >
    > base.Dispose(disposing);
    > }
    >
    > #endregion
    >
    > // WEB SERVICE EXAMPLE
    >
    > [WebMethod]
    > [SoapDocumentMethodAttribute(Binding="SampleBinding")]
    > public void StoreUser(User userData)
    > {
    > }
    > }
    >
    >
    > and here is the definition of the input parameter of type User ( a
    > complextype):
    >
    >

    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://acme.com/2004/S
    ampleService/DataTypes")]
    > public class User
    > {
    > public string firstname;
    > public string lastname;
    > }
    >
    >
    >
    >
    >
    >
    > "Youcef" wrote:
    >
    > > I started developing an ASP.NET web service by explicitly
    > > designing the WSDL and separating the data type definitions into XSD
    > > files. I followed the steps described in the following MSDN article to
    > > enlist the help of VS.NET in doing this through the use of separate
    > > namespaces and the [WebServiceBindingAttribute]. See :
    > >
    > >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service08202002.asp
    > >
    > > But I found that I couldn't pass an XML Schema ComplexType (e.g. an
    > > address class) as an input parameter to one of the methods of the web
    > > service !! If I pass a simple type or I move the same complextype
    > > parameter as a return value from the method, VS.NET 2003 generates the
    > > right stuff and the method is listed among the available methods for
    > > the web service . I spent 2 days checking and re-checking everything
    > > to no avail. This must be a bug, but I couldn't find it mentioned
    > > anywhere. Has anybody tried this ?
    > >
     
    Dino Chiesa [Microsoft], Aug 23, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Bedford
    Replies:
    0
    Views:
    592
    Chris Bedford
    Aug 21, 2003
  2. Bert Leu
    Replies:
    1
    Views:
    467
    Cowboy \(Gregory A. Beamer\)
    Nov 23, 2007
  3. RH
    Replies:
    1
    Views:
    269
    Dino Chiesa [Microsoft]
    May 27, 2004
  4. mrnu

    wsdl.exe fails with WebMethods generated wsdl file

    mrnu, Jun 7, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    215
  5. Bert Leu

    Creating a Web Service (Service, not Client) from WSDL

    Bert Leu, Nov 23, 2007, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    281
    Cowboy \(Gregory A. Beamer\)
    Nov 23, 2007
Loading...

Share This Page