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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:21:45+00:00 2026-05-14T07:21:45+00:00

I have a web service that I want to access when it is added

  • 0

I have a web service that I want to access when it is added as a web reference to my C# project. A particular method in the web service takes a SQL query string and returns the results of the query as a custom type. When I add the web service reference, the method shows up as returning DataSet[] instead of the custom type. This is fine provided I can still somehow access the data returned from the query within those DataSet objects. I ran a particular query that should return 6 rows; I got back a DataSet[] array with 6 elements. However, when I iterate over those DataSet objects, none of them has any tables (via the Tables property on the DataSet). What gives? Where is my data?

The web service is tested and works when I use it as a data source in a Report Builder 2.0 report. I am able to send an XML SOAP query to the web service and get back XML results containing my data.

Here’s a sample of how I’m getting the DataSet[] array:

var service = new MyWebService
    {
        Credentials = System.Net.CredentialCache.DefaultCredentials
    };
DataSet[] dataSets = service.MethodThatReturnsQueryResults(queryString);

// The body of this loop is skipped:
foreach (DataSet ds in dataSets.Where(ds => ds.Tables.Count > 0))
{
    // extract data from DataSet ds
}

Edit: here is what the method looks like in the auto-generated Reference.cs that got created when I added the web reference:

[return: System.Xml.Serialization.XmlArrayItemAttribute("SomeCustomType")]
public System.Data.DataSet[] MethodThatReturnsQueryResults(
    string selectSQLQuery) {
        object[] results = this.Invoke("MethodThatReturnsQueryResults", 
            new object[] { selectSQLQuery});
    return ((System.Data.DataSet[])(results[0]));
}

So it’s definitely returning a System.Data.DataSet[], but I wonder if something is happening such that the custom type used in the web service, SomeCustomType, is not getting translated correctly in that auto-generated method, hence the empty DataSet objects. I’m hesitant to edit this auto-generated method. I have access to the web service code; should I do something to it to ensure SomeCustomType can be cast to DataSet[]?

Edit: I feel like I could do better if I just got back the raw XML SOAP response from the web service. How can I do this instead of getting the “translated” version that comes back as DataSet[]?

  • 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-14T07:21:45+00:00Added an answer on May 14, 2026 at 7:21 am

    I ended up removing the web service reference from my project and instead wrote a utility class for sending a SOAP request and getting the response back in XML, thanks to this tutorial. Here are a couple snippets:

    public XmlDocument SendSoapRequest(XmlDocument soapRequest)
    {
        var webRequest = getWebRequest();
        Stream requestStream = webRequest.GetRequestStream();
        soapRequest.Save(requestStream);
        requestStream.Close();
        WebResponse webResponse = webRequest.GetResponse();
        requestStream = webResponse.GetResponseStream();
        var soapResponse = new XmlDocument();
        soapResponse.Load(new XmlTextReader(new StringReader(
            new StreamReader(requestStream).ReadToEnd()
        )));
        return soapResponse;
    }
    
    private HttpWebRequest getWebRequest()
    {
        var webRequest = (HttpWebRequest)WebRequest.Create(Url);
        webRequest.Credentials = CredentialCache.DefaultCredentials;
        webRequest.Headers.Add("SOAPAction", SoapAction);
        webRequest.ContentType = ContentType;
        webRequest.Accept = AcceptHeader;
        webRequest.Method = RequestMethod;
        return webRequest;
    }
    

    I then use an XPath query to navigate the returned XmlDocument and get the data I want, the data that was not showing up in the DataSet[] that I got back from the web service when I used a web reference. I already had a class that implements IXmlSerializable so once I navigate the returned XML with XPath, I just pass an XmlReader to my class’s ReadXml method and the class instance gets populated.

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

Sidebar

Related Questions

I have a web service that I want to access through SOAP. But I
I have a web service that wish to call, and I want to pass
I want to call a web service that requires an authentication cookie. I have
I have a web service that returns this string via the jQuery $.ajax() call
I have a web service that requires a two part query to fully get
I have access to an web service that returns an XML or JSON. Since
I have a trivial .Net 2.0 SOAP web service. I want to access it
I have a webservice that I want to query for updates immediately after a
I have web service urls that were working fine and are now returning the
I have a web service that requires special headers to be sent in the

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.