Showing posts with label generated. Show all posts
Showing posts with label generated. Show all posts

Wednesday, March 28, 2012

Change Object name in generated WSDL

Good day,

I have a Web Method that uses a simple custom object, name Client, as a parameter, and also returns a Client.

However, in the generated WSDL, I want "element name="Client" " to be changed to "element name="THE_CLIENT", but without changing the class name.

Is there a way to specify that an object should have another name in the wsdl, Something like [WebMethod(Description="DESCRIPTION")], but for a class?

Thank you, have a nice day!

Hi,

I think this link provide all information you need:http://msdn2.microsoft.com/en-us/library/2baksw0z.aspx

By default, an XML element name is determined by the class or member name. In a simple class named Book, a field named ISBN will produce an XML element tag <ISBN>, as shown in the following example.

Visual Basic

Copy Code

PublicClass BookPublic ISBNAsStringEndClass' When an instance of the Book class is serialized, it might' produce this XML:' <ISBN>1234567890</ISBN>.

C#

Copy Code

publicclass Book{publicstring ISBN;}// When an instance of the Book class is serialized, it might// produce this XML:// <ISBN>1234567890</ISBN>.

This default behavior can be changed if you want to give the element a new name. The following code shows how an attribute enables this by setting theElementName property of aXmlElementAttribute.

Visual Basic

Copy Code

PublicClass TaxRates < XmlElement(ElementName ="TaxRate")> _Public ReturnTaxRateAsDecimalEndClass

C#

Copy Code

publicclass TaxRates{ [XmlElement(ElementName ="TaxRate")]public decimal ReturnTaxRate;}

For more information about attributes, seeExtending Metadata Using Attributes. For a list of attributes that control XML serialization, seeAttributes That Control XML Serialization.

Best Regards

Monday, March 26, 2012

cascadingdropdowns when only one listitem

I am happily using cascading dropdowns for a three-level stack. In some cases, there is only one item in the generated list apart from the select prompt. Common sense and good design suggests that the one item should be auto-selected but this has not been implemented in the Toolkit.

I tried to implement it by setting the selected attribute (third parameter) to 'true' in the Web service. This worked for the displayed ddl, but the underlying value was not set . Hence the next level in the dropdown failed because no value was supplied.

Is this a bug or am I doing something wrong?

The relevant line in the VB Web Service (PageMethod) is:

values.Add(

New CascadingDropDownNameValue(sCompany, sCompanyId,True))

If I do not use the third parameter, I get the standard result with my Prompt showing in the ddl, and everything working when I actually select the one item.

This sounds like a bug. Could you whip up a quick sample page demonstrating the problem and file the issue at CodePlex?

http://www.codeplex.com/WorkItem/List.aspx?ProjectName=AtlasControlToolkit

Thanks!