Web service and Complex Types

M

Mark

I have built Web service that allows me to send input
parameters as a complex type:

public class User
{
public string FirstName;
public string LastName
}

[WebMethod]
public void UpdateUserDetails(User user)
{string fn = user.FirstName; string ln =
user.LastName}

This works fine, assuming I am only sending through a
single update request for User:

<ns0:UpdateUserDetails xmlns="http://MyCompany">
<FirstName>John</FirstName>
<LastName>Doe</LastName>
</ns0:DataFile>

What I would like is be able to update multiple Users
with a single XML document:

<ns0:UpdateUserDetails xmlns="http://MyCompany">
<User xmlns="">
<FirstName>John</FirstName>
<LastName>Doe</LastName>
</User>
<User xmlns="">
<FirstName>Jane</FirstName>
<LastName>Doe</LastName>
</User>
</ns0:UpdateUserDetails>

How should I build a collection class for to contain
multiple instances of User and call this from my Method?

Thanks
Mark
 
T

Tomas Restrepo \(MVP\)

Mark,
I have built Web service that allows me to send input
parameters as a complex type:

public class User
{
public string FirstName;
public string LastName
}

[WebMethod]
public void UpdateUserDetails(User user)
{string fn = user.FirstName; string ln =
user.LastName}

This works fine, assuming I am only sending through a
single update request for User:

<ns0:UpdateUserDetails xmlns="http://MyCompany">
<FirstName>John</FirstName>
<LastName>Doe</LastName>
</ns0:DataFile>

What I would like is be able to update multiple Users
with a single XML document:

<ns0:UpdateUserDetails xmlns="http://MyCompany">
<User xmlns="">
<FirstName>John</FirstName>
<LastName>Doe</LastName>
</User>
<User xmlns="">
<FirstName>Jane</FirstName>
<LastName>Doe</LastName>
</User>
</ns0:UpdateUserDetails>

How should I build a collection class for to contain
multiple instances of User and call this from my Method?

[WebMethod]
public void UpdateUserDetails(User[] users)
 

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

Top