德尔福SOAP信封和WCF

德尔福SOAP信封和WCF

本文介绍了德尔福SOAP信封和WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作系统,提供了一个SOAP接口。一说要使用的界面系统为codeD在Delphi 7的Web服务开发与WCF,基本的HTTP绑定,SOAP 1.1。

I am working on a system that provides a soap interface. One of the systems that are going to use the interface is coded in Delphi 7. The web service is developed with WCF, basic http binding, SOAP 1.1.

如果我使用SOAP UI(JAVA),服务工作正常。但是,德尔福似乎在这里做特别的事情;)

If I use SOAP UI (JAVA), the service works properly. But Delphi seems to do special things here ;)

这是怎样的消息看起来像SOAP UI:

This is how the message looks like in SOAP UI:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.xxx.de/xxx">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:GetCustomer>
         <!--Optional:-->
         <ser:GetCustomerRequest> <!-- this is a data contract -->
            <ser:Id>?</ser:Id>
         </ser:GetCustomerRequest>
      </ser:GetCustomer>
   </soapenv:Body>
</soapenv:Envelope>

我不是一个Delphi开发者,但我开发了一个简单的测试客户端,看看有什么地方出了错。这是什么德尔福将作为SOAP信封。

I am not a delphi developer , but I developed a simple test client to see what's going wrong. This what Delphi sends as a SOAP envelope.

<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" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS2="http://services.xxx.de/xxx">
    <NS1:GetCustomer xmlns:NS1="http://services.xxx.de/xxx">
      <GetCustomerRequest href="#1"/>
    </NS1:GetCustomer>
    <NS2:GetCustomerRequest id="1" xsi:type="NS2:GetCustomerRequest">
      <Id xsi:type="xsd:int">253</Id>
    </NS2:GetCustomerRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

WCF抛出一个错误,是德语单词......;)

WCF throws an error that is in German language... ;)

居wurde DAS的EndElement身体AUS命名空间http://schemas.xmlsoap.org/soap/envelope/erwartet。 Gefunden wurde元素NS2:GetCustomerRequestAUS命名空间http://services.xxx.de/xxx。 Zeile 1,位置599。

指像

美体预期。但是相反的元素。NS2:GetCustomerReques发现

现在我的问题是:我可以以某种方式改变德尔福创建信封的方式吗?或者是做出这样的消息格式WCF的工作方式?任何帮助是极大AP preciated!

Now my questions is: Can I somehow change the way Delphi creates the envelope? Or are the ways to make WCF work with such message formats? Any help is greatly appreciated!

推荐答案

相反的是有些人在这里似乎暗示,德尔福未发送的无效的SOAP,它只是简单地发送 RPC / EN codeD SOAP。这很容易从所有的 XSI认识到:键入属性。 RPC / EN coded不符合WS-I,但它的仍然有效的SOAP。

Contrary to what some people here seem to be implying, Delphi is not sending invalid SOAP, it is simply sending RPC/Encoded SOAP. It's very easy to recognize from all the xsi:type attributes. RPC/Encoded is not WS-I compliant but it is still valid SOAP.

WCF,默认情况下,使用文档/文字/包裹 SOAP格式,德尔福7不能处理都在服务器端,你必须使客户端上的一些调整。

WCF, by default, uses the Document/Literal/Wrapped SOAP format, which Delphi 7 can't handle at all on the server side and you have to make some adjustments on the client side.

最简单的方法是简单地告诉Delphi使用文档/文字风格。你可以通过打开 soLiteralParams THttpRio.Converter.Options 。这告诉德尔福没有放松的参数,你所看到的。 文档方面的东西,德尔福WSDL进口商通常可以找出,所以你应该不需要担心。

The simplest solution is to simply tell Delphi to use the Document/Literal style. You do that by turning on soLiteralParams in the THttpRio.Converter.Options. This tells Delphi not to "unwind" the parameters as you are seeing. The "Document" aspect is something that the Delphi WSDL importer can usually figure out so you shouldn't need to worry about that.

另外一个解决办法是告诉WCF服务使用RPC / EN codeD的风格,你可以做到通过添加下列属性的服务:

The other solution is to tell the WCF service to use RPC/Encoded style, which you can do by adding the following attributes to the service:

[ServiceContract]
[XmlSerializerFormat(Style = OperationFormatStyle.Rpc,
    Use = OperationFormatUse.Encoded)]
public interface IMyService
{
    // etc.
}

二是不建议,因为,正如我刚才所说,RPC / EN coded不符合WS-I,但尽管如此,多数SOAP工具包都认识它,所以我在这里列举作为一种可能性。

The second is not recommended because, as I mentioned earlier, RPC/Encoded is not WS-I compliant, but nevertheless most SOAP toolkits do recognize it, so I list it here as a possibility.

这篇关于德尔福SOAP信封和WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 18:33