Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
Chona11714.3K

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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 895
1 OriginalGriff 523
2 thatraja 245
3 Abhinav S 243
4 Emre Ataseven 200
0 Sergey Alexandrovich Kryukov 8,142
1 OriginalGriff 4,665
2 Peter Leow 3,774
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 1 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid