修复无效的SOAP请求 [英] Fixing Invalid SOAP Requests

查看:325
本文介绍了修复无效的SOAP请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

在回答之前,请阅读!而且请不要给我一个结果,您很快就会用Google搜索,我需要一个真正处理过这个问题并且可以给我一个实际答案的人.

我有一个调用我的.net Web服务的delphi程序,问题是参数总是以空值的形式出现,我所需要的只是通过粘贴一个简单的字符串,所以我在Global.asax代码中内置了一些代码. br/>

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);
    
            }
            
        }



这捕获了传入的肥皂请求

来自delphi的请求如下:



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>



我需要将其更改为跟随"(这是来自.net客户端程序的内容):



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>


我知道如何处理字符串,但是如何在请求输入流到达Web服务并运行命令并返回结果之前对其进行处理?

在此先感谢您


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

推荐答案

找到了解决方案.

它涉及从SoapExtension继承并更改
中的数据
公共重写void ProcessMessage()

用于在反序列化之前重写流的方法.

将在周末撰写有关此内容的文章.
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.


这篇关于修复无效的SOAP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆