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 3360132
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:57:21+00:00 2026-05-18T02:57:21+00:00

I have a followup question to this question . I’m writing a web service

  • 0

I have a followup question to this question.

I’m writing a web service which dynamically calls other web services, using the WSProxy class found here.

Using WSProxy returns an object with a dynamic type, depending on the web service method called. For example, if I’m calling a method that returns…

<StateCodes>
    <StateCode>
        <Code>AL</Code>
        <Name>Alabama</Name>
    </StateCode>
    <!-- and so on -->
</StateCodes>

then the object is of the type StateCodes[].

If I’m calling a method that returns …

<GetVehicleMakes>
    <VehicleMakes>
      <Vehicle_Make_Code>00</Vehicle_Make_Code>
      <Vehicle_Make_Description>Ford</Vehicle_Make_Description>
    </VehicleMakes>
    <VehicleMakes>
      <Vehicle_Make_Code>01</Vehicle_Make_Code>
      <Vehicle_Make_Description>Toyota</Vehicle_Make_Description>
    </VehicleMakes>
    <!-- and so on -->
</GetVehicleMakes>

then the object is of the type GetVehicleMakes[].

I can’t declare a class type beforehand because the class type of the returned object is determined by the web service method called, and the web service method is determined at runtime. There are dozens of methods with different return types on the local service I’m testing against. I don’t get to know the type of the returned object before runtime, because any method from any web service could be called.

When I try to return the object straight up, like so:

[WebMethod]
public object RunService(string webServiceAsmxUrl, string serviceName, string methodName, string jsonArgs)
{

    WSDLRuntime.WsProxy wsp = new WSDLRuntime.WsProxy();

    // Convert JSON to C# object.
    JavaScriptSerializer jser = new JavaScriptSerializer();
    var dict = jser.Deserialize<Dictionary<string,object>>(jsonArgs);

    object result = wsp.CallWebService(webServiceAsmxUrl, serviceName, methodName, dict);

    // This line produces the error.
    return result;

}

I can insert a breakpoint at the return result line, and browse my result object. For example, when I call the StateCodes method, the result variable is the StateCodes[] array.

However, once return result runs, the XML parser won’t have it.

System.InvalidOperationException: The type StateCodes[] may not be used in this context.

I’ve searched for answers, and I see terms like, “reflection” and “serialization” coming up, but I am very new to C# and don’t know if these are what I want or how they work.
I’m using C# 3.5.

  • 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-18T02:57:22+00:00Added an answer on May 18, 2026 at 2:57 am

    It looks like you need to return the xml that is returned from the service call. You can’t return the object directly because the top-level service (the one that has a return type of object) is not generated at runtime; it is defined when its wsdl is consumed.

    Long story short, you should change the return type of your top-level WebMethod to be string and serialize result manually in order to do what you want. Then the client (who presumably knows what they expect to get back from the service that they are requesting via webServiceAsmxUrl, serviceName, and methodName) can deserialize the result themselves.

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

Sidebar

Related Questions

NOTE: This is a followup to my question here. I have a program that
This is a followup to my last question . I now have a byte[]
Hey guys this is a followup to my previous question . I now have
This is a followup to the solution for this question. I am using jQuery's
This is a followup to a question I asked yesterday: Have you ever had
[ Note: This is a followup to the question about running an Android service
This is kind of a followup on my previous question . I have an
I have a similar situation to this question , which was already posted. Koraktor
This is kind of a followup to this question . I have the following
This is a followup question from a previous question, which is hopefully a little

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.