Board index » delphi » SoapHeader sent by .NET not recognised

SoapHeader sent by .NET not recognised


2007-09-15 10:30:42 AM
delphi152
I have written a Delphi 7 web service that requires a soap header.
It retrieves the soap header in the invokable class by using:
Headers := (Self as ISOAPHeaders);
Headers.Get(RequestorHeader, TSOAPHeader(Header));
It has had no problem retrieving Header: RequestorHeader from
requests that are sent from a client developed in D7.
However the Header variable comes out at Nil when it attempts to
retrieve the soap header if sent by a client I have developed using
Turbo Delphi for .NET
By using SOAPInvokerBeforeDispatchEvent in the Delphi 7 webservice
I've been able to trap the incoming requests.
The one that doesn't work (.NET) looks like this:
-------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="tempuri.org/"
xmlns:types="tempuri.org/encodedTypes"
xmlns:xsi="www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="www.w3.org/2001/XMLSchema">
<soap:Header>
<q1:RequestorHeader id="h_id1" xmlns:q1="urn:SCDataServerIntf">
<UserName xsi:type="xsd:string">Ian</UserName>
<Password xsi:type="xsd:string">xxxxx</Password>
</q1:RequestorHeader>
</soap:Header>
<soap:Body
soap:encodingStyle="schemas.xmlsoap.org/soap/encoding/">
<q1:GetServices xmlns:q1="urn:SCDataServerIntf-ISCDataServer" />
</soap:Body>
</soap:Envelope>
--------------------------------
For comparison, the SOAP envelope sent by Delphi 7 client (which works) looks like
this:
---------------------------------
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="www.w3.org/2001/XMLSchema"
xmlns:xsi="www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header
SOAP-ENV:encodingStyle="schemas.xmlsoap.org/soap/encoding/"
xmlns:NS1="urn:SCDataServerIntf-ISCDataServer"
xmlns:NS2="urn:SCDataServerIntf">
<NS1:RequestorHeader xsi:type="NS2:RequestorHeader">
<UserName xsi:type="xsd:string">Ian</UserName>
<Password xsi:type="xsd:string">xxxxxx</Password>
<DataID xsi:type="xsd:string"></DataID>
</NS1:RequestorHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body
SOAP-ENV:encodingStyle="schemas.xmlsoap.org/soap/encoding/">
<NS3:GetServices xmlns:NS3="urn:SCDataServerIntf-ISCDataServer"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
----------------------------------
There's nothing in the imported interface file in .NET that indicates
where the id="h_id1" comes from (in case that is the problem).
Any ideas?
Ian.
 
 

Re:SoapHeader sent by .NET not recognised

Hello Ian,
The XML excerpts differ about the namespace of the 'RequestorHeader'
element:
The first one has 'RequestorHeader' in the "urn:SCDataServerIntf" namespace.
<q1:RequestorHeader id="h_id1" xmlns:q1="urn:SCDataServerIntf">
... while the second one has 'RequestorHeader' in
"urn:SCDataServerIntf-ISCDataServer"
<SOAP-ENV:Header
SOAP-ENV:encodingStyle="schemas.xmlsoap.org/soap/encoding/"
xmlns:NS1="urn:SCDataServerIntf-ISCDataServer"
xmlns:NS2="urn:SCDataServerIntf">
<NS1:RequestorHeader xsi:type="NS2:RequestorHeader">
I suspect that to be the problem. Of course, the WSDL contains the answer to
which one is correct. Because we had similar problems in this area, I would
be tempted to assumed that it is a problem with the importer incorrectly
translating the info from the WSDL into a Delphi model. If you can point me
to (or email) the WSDL, I would be happy to investigate. If that is not possible,
I would recommend the runtime/importer update at the following link:
cc.codegear.com/Item/24535
Cheers,
Bruneau.
 

Re:SoapHeader sent by .NET not recognised

Hi Bruneau,
Thank you so much for your help.
Your advice caused me to closely re-examine differences in the
WSDL copied by the .NET Web Reference, and the WSDL
currently being produced by the Delphi 7 web service, paying particular
attention to the namespaces.
I DID find inconsistencies in the WSDL's as you expected, most
likely due to some "small" changes I had made in the underlying
D7 web service (that I really didn't think would break anything)
since having imported it into my .NET client.
A fresh re-import of the web service into .NET *fixed* the problem.
My apologies for making this obvious mistake.
Ian.
"Jean-Marie Babet" <XXXX@XXXXX.COM>writes
Quote
Hello Ian,

The XML excerpts differ about the namespace of the 'RequestorHeader'
element:

The first one has 'RequestorHeader' in the "urn:SCDataServerIntf"
namespace.

<q1:RequestorHeader id="h_id1" xmlns:q1="urn:SCDataServerIntf">


... while the second one has 'RequestorHeader' in
"urn:SCDataServerIntf-ISCDataServer"

<SOAP-ENV:Header
SOAP-ENV:encodingStyle="schemas.xmlsoap.org/soap/encoding/"
xmlns:NS1="urn:SCDataServerIntf-ISCDataServer"
xmlns:NS2="urn:SCDataServerIntf">
<NS1:RequestorHeader xsi:type="NS2:RequestorHeader">


I suspect that to be the problem. Of course, the WSDL contains the answer
to
which one is correct. Because we had similar problems in this area, I
would
be tempted to assumed that it is a problem with the importer incorrectly
translating the info from the WSDL into a Delphi model. If you can point
me
to (or email) the WSDL, I would be happy to investigate. If that is not
possible,
I would recommend the runtime/importer update at the following link:

cc.codegear.com/Item/24535

Cheers,

Bruneau.


 

Re:SoapHeader sent by .NET not recognised

Hello,
No need to apologize... I constantly do that kind of thing. The QA engineer
who runs the tests against .NET/Axis services often reports how a test would
start failing or the description of a bug report I filed would be incorrect,
etc. And it is often due to these "small" changes I make to the services, not
realizing the impact on an existing test or bug report.
I'm glad things are working again!
Chers,
Bruneau.