Hi TBQ,
Regarding on the ASP.NET webservice WSDL generation, it does provides some
means for you to control the element name or schema type name of the .NET
class/types used in webservice methods as parameter or return value. For
example, you can use XmlTypeAttribute to specify the type name that will
occur in wsdl schema, and you can use XmlRoot/XmlElement attribute and the
SoapDocumentMethod attribute to control the element name of the webservice
request/response(and its parameters) in the underlying serialized SOAP
message.
Here is a very simple example to demonstrate this. The webservcie "GetData"
operation return a complex type. I've used some XML serialization and
webservice attributes to format the schema type and element name that will
occur in the generated WSDL:
Quote:
service code
public class DataService : System.Web.Services.WebService
|
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
[SoapDocumentMethod(RequestElementName="DataReq",
ResponseElementName="DataRep")]
public ComplexData GetData()
{
ComplexData data = new ComplexData()
{
StringValue = "aaa",
IntValue = 23,
BoolValue = true
};
return data;
}
}
[XmlRoot(ElementName="DataRoot")]
[XmlType(TypeName="SimpleComplexDataType")]
public class ComplexData
{
[XmlElement]
public string StringValue { get; set; }
[XmlElement]
public int IntValue { get; set; }
[XmlElement]
public bool BoolValue { get; set; }
}
Quote:
generated WSDL schema types fragment
wsdl:types
|
<s:schema elementFormDefault="qualified"
targetNamespace="http://tempuri.org/">
.........................
<s:element name="DataReq">
<s:complexType />
</s:element>
<s:element name="DataRep">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="DataRoot"
nillable="true" type="tns:SimpleComplexDataType" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="SimpleComplexDataType">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="StringValue"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="IntValue"
type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="BoolValue"
type="s:boolean" />
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
..................
<wsdl:message name="GetDataSoapIn">
<wsdl

art name="parameters" element="tns

ataReq" />
</wsdl:message>
<wsdl:message name="GetDataSoapOut">
<wsdl

art name="parameters" element="tns

ataRep" />
</wsdl:message>
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg (AT) microsoft (DOT) com.
--------------------
Quote:
From: =?Utf-8?B?VG9yZQ==?= <TBQ (AT) newsgroup (DOT) nospam
Subject: How to control parameter type names in WSDL?
Date: Tue, 18 May 2010 09:36:01 -0700
I have a .NET 3.5 web service exposed as a 2.0 style web service (used by
other apps also) with several exposed operations that all take the same
complex parameter type, and also returns the same complex type (tried both
function return value and Byref declarations). In the WSDL and the
reference
map, VS2008 generates composite names - apparently
WebMethodName>Response<ParameterName>.
Is there any way to get the generated WSDL to use a single complex type
for
parameters that originally are declared as the same type in the web
methods,
preferably with a non-compond type name? It will have to be done in a way
that allows repeated generation (so no hand-tweaking), as we will continue
to
add to this web service in the future, and would like to avoid regression
testing of all the apps using it. |