Click here to Skip to main content
12,501,010 members (40,535 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET service Web
Hi Guys

Before you answer read! and please dont give me a result you quickly Googled, i need someone who actualy dealt with this and can give me an actual answer.

I have a delphi program that calls my .net web service, problem is the parameters always comes through as a null value , all i need is to pasre a simple string through so I built a bit of code into my Global.asax code.

protected void Application_BeginRequest(object sender, EventArgs e)
        {
            string name = HttpContext.Current.Request.Url.ToString();
            if (name.Contains("PMA/PMAService.asmx"))
            {
                // Create byte array to hold request bytes
                byte[] inputStream = new byte[HttpContext.Current.Request.ContentLength];
 
                // Read entire request inputstream
                HttpContext.Current.Request.InputStream.Read(inputStream, 0, inputStream.Length);
 
                //Set stream back to beginning
                HttpContext.Current.Request.InputStream.Position = 0;
                
                //Get  XML request
                string requestString =UTF8Encoding.UTF8.GetString(inputStream);
    
            }
            
        }

This captures the incoming soap requests

From delphi the request is as follow:
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<saySomething xmlns="http://tempuri.org/"><xsd:data>hello</xsd:data></saySomething>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I need to change this into Following (this is what comes from a .net client program):

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<saySomething xmlns="http://tempuri.org/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><data>hello</data></saySomething>
</s:Body>
</s:Envelope>
I know how to manipulate the string but how do i manipulate the request input stream before it hits the web service and runs the command and returns the result ?

Thank you in advance
Posted 31-Jul-12 20:51pm
L Viljoen5.1K

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

found a solution.

It involves inherriting from the SoapExtension and changing data in the

public override void ProcessMessage()

Method in order to rewrite the stream beforeit becomes deserialized.

Will write an article regarding this over the weekend.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 1 Aug 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100