HighTechTalks DotNet Forums  

How to control parameter type names in WSDL?

ASP.net Web Services microsoft.public.dotnet.framework.aspnet.webservices


Discuss How to control parameter type names in WSDL? in the ASP.net Web Services forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Tore
 
Posts: n/a

Default How to control parameter type names in WSDL? - 05-18-2010 , 11:36 AM






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.

Reply With Quote
  #2  
Old   
Steven Cheng
 
Posts: n/a

Default RE: How to control parameter type names in WSDL? - 05-20-2010 , 04:23 AM






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


Quote:
data type definition
[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">
<wsdlart name="parameters" element="tnsataReq" />
</wsdl:message>
<wsdl:message name="GetDataSoapOut">
<wsdlart name="parameters" element="tnsataRep" />
</wsdl:message>
Quote:
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.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.