Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 229893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:48:14+00:00 2026-05-11T19:48:14+00:00

Background: I’m in the process of creating a web service using ASP.NET 2.0. This

  • 0

Background:
I’m in the process of creating a web service using ASP.NET 2.0. This web service provides another interface to an existing web form which contains selection boxes dynamically populated from a database.

My first draft of the web service accepted a string for each of these and then ensured that it was valid, throwing back an error if it wasn’t. However the consumer of the web service has asked, since the possible values aren’t likely to change all that often, that we provide enumerated values in the WSDL.

I am reluctant to create an enumeration with my web service code, so I have instead altered the generated WSDL file and instructed my web service to use that instead of inspecting my classes to generate it.

WSDL:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://example.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://example.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://example.org/">
      <s:element name="MyMethod">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="myClass" type="tns:MyClass" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:complexType name="MyClass">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="MyString" type="tns:MyStringPossibleValues" />
        </s:sequence>
      </s:complexType>
      <s:element name="MyMethodResponse">
        <s:complexType />
      </s:element>
      <s:simpleType name="MyStringPossibleValues">
        <s:restriction base="s:string">
          <s:enumeration value="alpha" />
          <s:enumeration value="bravo" />
        </s:restriction>
      </s:simpleType>
    </s:schema>
  </wsdl:types>
  <wsdl:message name="MyMethodSoapIn">
    <wsdl:part name="parameters" element="tns:MyMethod" />
  </wsdl:message>
  <wsdl:message name="MyMethodSoapOut">
    <wsdl:part name="parameters" element="tns:MyMethodResponse" />
  </wsdl:message>
  <wsdl:portType name="ExternalAccessSoap">
    <wsdl:operation name="MyMethod">
      <wsdl:input message="tns:MyMethodSoapIn" />
      <wsdl:output message="tns:MyMethodSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:portType name="ExternalAccessHttpGet" />
  <wsdl:portType name="ExternalAccessHttpPost" />
  <wsdl:binding name="ExternalAccessSoap" type="tns:ExternalAccessSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="MyMethod">
      <soap:operation soapAction="http://example.org/MyMethod" style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="ExternalAccessSoap12" type="tns:ExternalAccessSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="MyMethod">
      <soap12:operation soapAction="http://example.org/MyMethod" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
</wsdl:definitions>

Webservice:

namespace Example.Service
{
    [WebService(Namespace = "http://example.org/")]
    [WebServiceBinding(
        ConformsTo = WsiProfiles.BasicProfile1_1,
        Location="ExternalAccess.wsdl",
        Name="ExternalAccessSoap",
        Namespace = "http://example.org/")]
    [ToolboxItem(false)]
    public class ExternalAccess : System.Web.Services.WebService
    {
        public class MyClass
        {
            public string MyString;
        }

        [WebMethod]
        [SoapDocumentMethod(
            Action = "http://example.org/MyMethod",
            RequestNamespace = "http://example.org/",
            Binding="ExternalAccessSoap")]
        public void MyMethod(MyClass myClass)
        {
        }
    }
}

The problem:
As the WSDL specifies an enumeration for MyString and the code specified a string type, ASP.NET does not manage to map the fields correctly.

Is there an attribute I can use to instruct the deserialiser to populate the string field with the value of the enumeration?

Regards,

Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:48:14+00:00Added an answer on May 11, 2026 at 7:48 pm

    Having gone through the process of creating a soap extension to do this for me I discovered that MyString wasn’t actually being sent to my web service.

    This was because the test application for this service was built in .NET also and, when building the request object, the MyStringSpecified property of the generated proxy class was overlooked. This then prevented the enumerated value being sent as part of the SOAP request.

    When this property was set to true, the enumerated value was successfully assigned to the MyString field in the webservice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I am customizing an existing ASP .NET / C# application. It has it's
Background: I'm testing a function within an ASP.NET 4.0 (Web Forms not MVC) and
Background: I have a website that has been built with ASP.NET 2.0 and is
Background I'm trying to implement a simple web server part as a web interface
BACKGROUND: Co-worker Adam has been using Google refine to process database downloads with much
Background: I have a Visual Studio solution consisting of a website + REST web-service
Background: At my company we are developing a bunch applications that are using the
Background I am writing and using a very simple CGI-based (Perl) content management tool
Background: My organization uses Microsoft .Net (3.5) with SQL Server 2005 as back end.
Background - I need a framework/approach to managed database updates for a .NET Winforms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.