从ASP使用的SOAPClient调用ASP

从ASP使用的SOAPClient调用ASP

本文介绍了从ASP使用的SOAPClient调用ASP.NET Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET web服务与线沿线的:

I have an ASP.NET webservice with along the lines of:

[WebService(Namespace = "http://internalservice.net/messageprocessing")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class ProvisioningService : WebService
{
    [WebMethod]
    public XmlDocument ProcessMessage(XmlDocument message)
    {
        // ... do stuff
    }
}

我使用的是这样调用从ASP Web服务:

I am calling the web service from ASP using something like:

provWSDL = "http://servername:12011/MessageProcessor.asmx?wsdl"
Set service = CreateObject("MSSOAP.SoapClient30")
service.ClientProperty("ServerHTTPRequest") = True
Call service.MSSoapInit(provWSDL)

xmlMessage = "<request><task>....various xml</task></request>"
result = service.ProcessMessage(xmlMessage)

我遇到的问题是,当XML到达的ProcessMessage方法,web服务管道尚未添加沿途默认名称空间。也就是说,如果我把里面的ProcessMessage的(XmlDocument的消息)断点我看到:

The problem I am encountering is that when the XML reaches the ProcessMessage method, the web service plumbing has added a default namespace along the way. i.e. if I set a breakpoint inside ProcessMessage(XmlDocument message) I see:

<request xmlns="http://internalservice.net/messageprocessing">
  <task>....various xml</task>
</request>

当我捕获数据包在电线上,我可以看到,通过SOAP工具包发送的XML是从由.NET WS客户端发送稍有不同。 SOAP工具包发送:

When I capture packets on the wire I can see that the XML sent by the SOAP toolkit is slightly different from that sent by the .NET WS client. The SOAP toolkit sends:

<SOAP-ENV:Envelope
    xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema"
    xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body>
        <ProcessMessage xmlns="http://internalservice.net/messageprocessing">
            <message xmlns:SOAPSDK4="http://internalservice.net/messageprocessing">
                <request>
                    <task>...stuff to do</task>
                </request>
            </message>
        </ProcessMessage>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

虽然.NET客户端发送:

Whilst the .NET client sends:

<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <ProcessMessage xmlns="http://internalservice.net/messageprocessing">
            <message>
                <request xmlns="">
                    <task>...stuff to do</task>
                </request>
            </message>
        </ProcessMessage>
    </soap:Body>
</soap:Envelope>

这是这么长时间,因为我用的ASP / SOAP工具包调用到.NET Web服务,我不记得所有的手段高明/ SOAP福我用来拉来解决这样的东西。

It's been so long since I used the ASP/SOAP toolkit to call into .NET webservices, I can't remember all the clever tricks/SOAP-fu I used to pull to get around stuff like this.

任何想法?一个解决方案是敲了一个COM可调用.NET代理,它使用XML作为字符串参数并调用WS代表我的,但它的复杂性/工作多一层我希望不要做。

Any ideas? One solution is to knock up a COM callable .NET proxy that takes the XML as a string param and calls the WS on my behalf, but it's an extra layer of complexity/work I hoped not to do.

推荐答案

我解决了这一点:

在SOAP客户端的请求的节点,从拿起默认命名空间:

The SOAP client request node was picking up the default namespace from:

<ProcessMessage xmlns="http://internalservice.net/messageprocessing">

添加一个空的默认命名空间由ASP客户端发送的XML重写此行为:

Adding an empty default namespace to the XML sent by the ASP client overrides this behaviour:

xmlMessage = "<request xmlns=''><task>....various xml</task></request>"

这篇关于从ASP使用的SOAPClient调用ASP.NET Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 13:51