Christian responds to my earlier question on a comment: "As you are using a Document/literal ASMX based Web Service which aims at *messages* and not *RPCs* (you know this distinction and the ongoing discussions ...), the top element of the serialized instance is just a signal for what kind of message is sent back to the original caller ... nothing more. The inbound message is GetCustomer and the outbound is GetCustomerResult - you see: just XML block :-)"
Thanks for the comment!. I understand what's going on with document/literal and the messages going back and forth, however, that was not what I was refering to.
You say the inbound message is GetCustomer and the outbound message is GetCustomerResult. Well, no, not really. The inbound message indeed is GetCustomer, but the outbound message, if you look at my original example, is actually GetCustomerResponse. The GetCusomerResult element is how the Customer object is being serialized. "That* is what I'm arguing about.
Allow me to present it with a counter example: Why couldn't this be the default SOAP answer:
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
string
string
This is indeed exactly what would happen if I had changed my Customer definition like this:
[ XmlRoot("Customer", Namespace="/schemas/customer") ]
public class Customer
{
...
}
2 Comments
archived from WordPress — closedOK, you are right here ... I mixed things up :-(
Sorry.
Cheers,
Christian
This is far from a stupid question. I really didn't know either. I thought maybe it was some form of convention, but like most things in .net, there is a reason behind it. I think it might have something to do with this example:
[WebMethod]
public Customer GetCustomer(out Customer c1)
{
Customer customer1 = new Customer();
Customer customer2 = new Customer();
customer1.name = "Ali";
customer1.phone = "555-1212";
customer2.name = "Tom";
customer2.phone = "555-5555";
c1 = customer1;
return customer2;;
}
Now, if you apply the XmlRoot tag to the Customer object, you now have two Customer elements in the same namespace. This is most likely why the return value is wrapped in the Result block.