Binding a WSDL file to a web service class

Y

Youcef

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 ?
 
Y

Youcef

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;
}
 
D

Dino Chiesa [Microsoft]

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


Youcef said:
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 said:
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 ?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top