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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:25:41+00:00 2026-05-14T14:25:41+00:00

I am in the process of setting up a web service for an external

  • 0

I am in the process of setting up a web service for an external client to connect to my client’s application and update some information. I went the ASMX route (the rest of the application runs on WCF) because I knew the external client could be very difficult to deal with and I was trying to keep everything as simple as possible. They also aren’t a .Net shop which makes things worse. After getting the service setup for them I provided the ASMX URL for them to see how to format the SOAP headers/message content. They have since come back and told me their tool is unable to send them in the format required by .Net and I can either come up with a different way to accept messages or we have to go with FTP.

Based on this I have been researching how to intercept their message, reformat it the way my service requires it (which means adding two lines), and then let it process. This path led me to SOAP Extensions which I have been trying to work with but can’t seem to figure out. When I have my sample application call the web service from the generated code Add Web Reference provides everything works great until I add in my extension. All it currently does is override ChainStream setting an internal stream equal to the one being passed in and returning a new stream, like this:

private Stream newStream = null;
private Stream oldStream = null;

public override Stream ChainStream(Stream stream)
{
    this.oldStream = stream;
    this.newStream = new MemoryStream();
    return newStream;
}

I also override ProcessMessage and in it take the contents of oldStream and set newStream equal to that and then write to a different stream with an XmlWriter. I take that new stream and using a StreamReader read it into a string, with the end goal being manipulating it here and setting newStream (which is being used by ChainStream) equal to the contents of this. Here is that piece:

    public override void ProcessMessage(SoapMessage message)
{
    switch (message.Stage)
    {
        case SoapMessageStage.BeforeDeserialize:
            this.Process();
            break;

        default: break;
    }
}

private void Process()
{
    this.newStream.Position = 0L;
    XmlTextReader reader = new XmlTextReader(this.oldStream);
    MemoryStream outStream = new MemoryStream();
    using (XmlWriter writer = XmlWriter.Create(outStream))
    {
        do { writer.WriteNode(reader, true); } while (reader.Read());
        writer.Flush();
    }
    outStream.Seek(0, SeekOrigin.Begin);
    StreamReader streamReader = new StreamReader(outStream);
    string message = streamReader.ReadToEnd();
    newStream = outStream;
    newStream.Seek(0, SeekOrigin.Begin);
    streamReader.Close();

}

By running this, which seems to me like it would be fine, my test application gets a 400 Bad Request back from the service. If I either don’t use the extension or I don’t do anything in ProcessMessage everything seems fine. Any suggestions to this?

As a side note, once I get this working with the generated code from the WSDL I will be moving to a WebRequest to try sending the message to the service. Currently that bombs out with a 415 Unsupported Media Type response. I’m trying to keep this post to one question but if anyone has any tips with using a WebRequest to connect to an ASMX service it would be much appreciated!

  • 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-14T14:25:41+00:00Added an answer on May 14, 2026 at 2:25 pm

    I realise this isn’t the answer you’re looking for but why not just use REST instead of SOAP? Since the main (only?) consumer of the service isn’t going to comply, trying to ‘fix’ their calls is just an extra layer of complexity.

    Instead, just use an aspx page that accepts data on the query string or with an xml request body, process it and then stream the xml (or other format) response back to them.

    You lose the Visual Studio SOAP “magic” which auto-generates type info etc. but since they aren’t using (or aren’t admitting to using) a language with a SOAP library, this doesn’t really help anyone.

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

Sidebar

Related Questions

We're in the process of developing a WCF REST web service which just receives
I'm in the process of setting up a database with customer information. The database
I am in the process of migrating a large scale web service to be
I need to know if a client of my web service has successfully received
I am setting up a WCF web service that hosts a Lucene.Net / AzureDirectory
I need to talk to some web service and thus I imported the WSDL.
I need to modify an existing Java SE process to expose a web service.
I'm building an Eclipse RCP application, and am in the process of setting up
I'm attempting to update some values in the web.config file from code during an
We are in the process of setting up a new development environment for about

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.