views:

328

answers:

1

I have a VB class in an .asmx file in Visual Studio 2008:

public class foo
 public bla as String
end class

It generates the wsdl value:

<s:complexType name="foo">
  <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="bla" type="s:string" /> 
  </s:sequence>
</s:complexType>

But what I want the wsdl to generate is:

<xs:element name="bla" type="xs:string" 
    sql:datatype="varchar(25)" minOccurs="1" maxOccurs="1">
</xs:element>

Is there a way to do this? Or can I edit the generated WSDL?

A: 

You can use The System.Xml.Serialization.XmlElementAttribute to mark the property IE:

<XmlElement(DataType := "varchar(25)")>

(my vb is a little rusty if this isn't correct syntax)

You can save off the WSDL and edit it, however, if you change the WSDL, a proxy generated from it may not be able to communicate with your service.

Edit: If you have the target schema, I would suggest that you use xsd.exe or wsdl.exe to generate the classes you need to serialize to valid documents according to that schema.

Joe Caffeine
-1: Even if this ran without error, why would it emit `sql:datatype`?
John Saunders
It wouldn't by itself, xml namespaces are generally defined as class level attributes.
Joe Caffeine