Delphi 2005 Web服务问题 [英] Delphi 2005 Web Services problem

查看:57
本文介绍了Delphi 2005 Web服务问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试通过Delphi访问Web服务时遇到问题。我已经在2007版的WSDLimp工具中使用了Java WSDL,看起来它已经正确创建了所有对象。但是当我创建一个调用该服务的测试程序时,每个对象都是空的。如果我将SOAPResponse对象转储到HTTPRIOAfterExecute方法中,则可以看到已经获得了格式正确的XML Soap数据包,其中包含了我希望的所有数据,但我无法通过这些对象访问它。那有什么我想念的吗?

I'm having an issue trying to access a web service through Delphi. I've consumed a java WSDL with the 2007 version of the WSDLimp tool and it looks like it's created all of the objects correctly. When I make a tester program however that calls the service every object is empty. If I dump the SOAPResponse object in the HTTPRIOAfterExecute method I can see that I've gotten back a properly formatted XML Soap packet that contains all the data I would expect, but I can't access it through the objects. So is there something I'm missing?

推荐答案

Web服务响应包含每个属性的别名名称空间。这些别名未在WSDL中定义。例如,WSDL包含一个名称空间 http://www.example.com/SomeService 并且该请求的别名在顶级节点中即时显示为xmlns:ns3 = http://www.example.com/SomeService。因此,响应中的属性看起来像ns3:somePropertyName = [value]。

The web service response contains aliased namespaces for each attribute. These aliases are not defined in the WSDL. For example, the WSDL contains a namespace of "http://www.example.com/SomeService" and the request aliases that on-the-fly as xmlns:ns3="http://www.example.com/SomeService" in the top level node. So attributes in the response look like ns3:somePropertyName="[value]".

在OPToSOAPDomConv单元的TSOAPDomConv.InitObjectFromSOAP中,它试图查找属性。名称,不带名称空间前缀。这导致查找失败,并且object属性保留为空。即使使用2007年的源文件,这种情况也会发生。

In the OPToSOAPDomConv unit, in the TSOAPDomConv.InitObjectFromSOAP, it's attempting to look up an attribute name without the namespace prefix. This is causing the look up to fail and the object property to be left blank. This is happening even with the 2007 source files.

我能看到的最好的解决方法是修改InitObjectFromSOAP例程。

The best fix I can see is to modify the InitObjectFromSOAP routine.

围绕4181行,添加:

Around line 4181, add:

  RemTypeRegistry.InfoToURI(PropList[i].PropType^, NS, PropName, IsScalar);

并更改AttrNode.HasAttribute以将NS变量作为第二个参数传递,如下所示:

and change the AttrNode.HasAttribute to pass the NS variable as a second parameter so it looks like:

  if AttrNode.HasAttribute(ExternalPropName, NS) then

此外,还有几行是SetObjectPropFromText调用。最后一个参数是属性值,您需要将Attr.Attributes [ExternalPropName]更改为

Also, a few lines down is a SetObjectPropFromText call. The last parameter is the attribute value, and you'll need to change Attr.Attributes[ExternalPropName] to

SetObjectPropFromText(Instance, PropList[I], AttrNode.GetAttributeNS(ExternalPropName, NS))

当然要声明NS, PropName和IsScalar变量。

And of course declare the NS, PropName and IsScalar vars.

这篇关于Delphi 2005 Web服务问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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