从 SOAP 请求中删除命名空间 [英] Removing the namespace from SOAP request

查看:34
本文介绍了从 SOAP 请求中删除命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经导入了一个 WSDL 并使用它来发送一个 SOAP 请求.它看起来像这样:

I have imported a WSDL and use it to send a SOAP request. It looks like this:

<?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>
        <Calculate xmlns="urn:xx.WSDL.xxxxxWebService">
            <ContractdocumentIn>
                <AL>
                ...More XML...

问题在于计算元素中的 xmlns="urn:xx.WSDL.xxxxxWebService" 部分.Web 服务不能接受这一点.Web 服务不喜欢这样的命名空间...
使用 SoapUI 我发现这个请求工作得很好:

The problem is the xmlns="urn:xx.WSDL.xxxxxWebService" part in the Calculate element. The web service cannot accept this. The web service doesn't like namespaces like this...
Using SoapUI I found this request to work just fine:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:col="http://example.com.service.xxx/">
    <SOAP-ENV:Body>
        <col:Calculate>
            <ContractdocumentIn>
                <AL>
                    ...More XML...

那么,如何将请求从第一个版本更改为第二个版本?(不使用肮脏的技巧!)
(如果这会导致正确的请求格式,重新导入不是问题.)

So, how do I change the request from the first to the second version? (Without using dirty tricks!)
(Re-importing is not a problem if this would result in the proper request format.)




再次重申:不允许使用肮脏的伎俩,例如入侵请求流以对其进行修改!

虽然我还没有完全测试过它,但似乎 C#/VS2010 和 Delphi 2010 也无法使用我尝试调用的 Web 服务.一个似乎是用 Java 编写的 Web 服务.SoapUI 恰好是用 Java 编写的,因此我们有一个 Java 客户端与 Java 服务通信,这似乎可以工作正好.但是还有其他客户吗?
无论如何,是时候再添加两个标签了:Java",因为它是一个 Java 服务,vs2010",因为 .NET 也不喜欢这个服务.
我正准备在 .NET 中围绕这个服务编写一个包装器,希望这会起作用......它没有.所以这是一个非常严重的缺陷,可能是Java缺陷...

And while I haven't completely tested it, it seems that C#/VS2010 and Delphi 2010 are also unable to use the web service that I'm trying to call. A web service that seems to be written in Java. SoapUI happens to be written in Java, thus we have a Java client talking to a Java service, which seems to work just fine. But any other client?
Anyways, time to add two more tags: "Java", since it's a Java service, and "vs2010" because .NET also dislikes this service.
And I was about to write a wrapper around this service in .NET, hoping that would work... It doesn't. So this is a very serious flaw, possibly a Java flaw...

推荐答案

如果服务期望:

  <col:Calculate>
     <ContractdocumentIn>
         <AL>

Delphi SOAP 正在发送...

and Delphi SOAP is sending...

    <Calculate xmlns="urn:xx.WSDL.xxxxxWebService">
        <ContractdocumentIn>
            <AL>

...问题在于 ContractdocumentIn 是一个不合格的元素,并且(直到 Delphi XE)Delphi SOAP 不支持作为操作顶级元素的不合格元素.顶层元素是函数的参数,无处存储底层元素必须是非限定的事实;对于映射到属性的元素,我们使用属性的索引来存储 IS_UNQL 标志.

... the problem is that ContractdocumentIn is an unqualified element and (until Delphi XE) Delphi SOAP did not support unqualified elements that are top level elements of an operation. Top level elements are parameters of the function and there is nowhere to store the fact that the underlying element must be unqualified; for elements that map to properties, we use the Index of the property to store away the IS_UNQL flag.

顺便说一句,没有必要使用前缀.服务将(应该)也接受:

BTW, it's not necessary to use a prefix. The Service will (should) also accept:

    <Calculate xmlns="urn:xx.WSDL.xxxxxWebService">
        <ContractdocumentIn xmlns="">
            <AL>

后者更冗长,但相当于前缀大小写.

The latter is more verbose but it's equivalent to the prefix case.

在 Delphi XE 中,导入程序存储了特定参数映射到非限定元素的事实,并且运行时会根据此信息进行操作.最近在一个线程中出现时,我已经在新闻组中发布了基于 D2010 和 D2007 的 XE 实现的补丁:

In Delphi XE the importer stores away the fact that a particular parameter maps to an unqualified element and the runtime acts on this information. I've posted patches based on the XE implementation for D2010 and D2007 in the newsgroup when it came up in a thread recently:

https://forums.embarcadero.com/thread.jspa?threadID=43057

如果有人需要访问它们(它们位于附件区域但可能已滚动),请给我发电子邮件,我会提供它们.[在 embarcadero dot com 的 bbabet]

If someone needs access to them (they were in the attachments area but might have scrolled off), please email me and I'll make them available. [bbabet at embarcadero dot com]

干杯,

布鲁诺

这篇关于从 SOAP 请求中删除命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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