Delphi7调用.NET2.0 web service时soapheader的问题(100分)

Q

qiusj

Unregistered / Unconfirmed
GUEST, unregistred user!
通过.net vs2005自己生成的客户端在调用web service时生成的SOAP XML是这样的<br>
代码:
&lt;?xml version=&quot;1.0&quot;? encoding=&quot;utf-8&quot;?&gt;<br>&lt;soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;<br>&lt;soap:Header&gt;<br>&lt;PDAuth xmlns=&quot;http://tempuri.org/&quot;&gt;<br>&lt;CompanyID&gt;2&lt;/CompanyID&gt;<br>&lt;AuthCode&gt;A6ACMHB1KEC5P9NA&lt;/AuthCode&gt;<br>&lt;ClientCode&gt;4459J64G25G68QV7ZJR8&lt;/ClientCode&gt;<br>&lt;/PDAuth&gt;<br>&lt;/soap:Header&gt;<br>&lt;soap:Body&gt;<br>&lt;GetProduct xmlns=&quot;http://tempuri.org/&quot;&gt;<br>&lt;lastUpdateTime&gt;2006-03-09T10:27:35.625+08:00&lt;/lastUpdateTime&gt;<br>&lt;/GetProduct&gt;<br>&lt;/soap:Body&gt;<br>&lt;/soap:Envelope&gt;
<br>这时在web service中可以正常取得PDAuth的值<br><br>在delphi7中通过HTTPRIO控件生成的SOAP XML是这样的<br>
代码:
&lt;?xml version=&quot;1.0&quot;?&gt;<br>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:SOAP-ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;&gt;<br>&lt;SOAP-ENV:Header SOAP-ENV:encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; xmlns:NS1=&quot;http://tempuri.org/&quot;&gt;<br>&lt;NS1:PDAuth&gt;<br>&lt;CompanyID&gt;2&lt;/CompanyID&gt;<br>&lt;AuthCode&gt;A6ACMHB1KEC5P9NA&lt;/AuthCode&gt;<br>&lt;ClientCode&gt;4459J64G25G68QV7ZJR8&lt;/ClientCode&gt;<br>&lt;/NS1:PDAuth&gt;<br>&lt;/SOAP-ENV:Header&gt;<br>&lt;SOAP-ENV:Body SOAP-ENV:encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;&gt;<br>&lt;NS2:GetArea xmlns:NS2=&quot;http://tempuri.org/&quot;/&gt;<br>&lt;/SOAP-ENV:Body&gt;<br>&lt;/SOAP-ENV:Envelope&gt;
<br>这时在web service中PDAuth的值都是NULL[:(]<br>谁有碰到同样的问题吗?该如何解决
 
这个问题还是我自己来回答好了,这是D6/D7的一个BUG,其实不仅是Soap header读不出来,就是正常传进去的参数也是读不出来的<br>解决的办法就是在<br>
代码:
 &nbsp;InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'http://tempuri.org/', 'utf-8');<br> &nbsp;InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'http://tempuri.org/HelloWorld');
<br>加上下面一行<br>[red]
代码:
 &nbsp;InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);
[/red]<br>[注:把ServiceSoap换成你的ServiceSoap的名字就可以了]
 
顶部