Problem upgrading web service client from Delphi 7 to Delphi XE

In trying to upgrade our web service client to Delphi XE we have now get a web service error of Invalid Format.

When we examine the SOAP request we see the following differences from Delphi 7 vs Delphi XE

In Delphi 7 we get

<SomeStuff xmlns="" xsi:nil="true" />

In Delphi XE we get

<SomeStuff xsi:nil="true" />

We have narrowed the failure down to these differences in the client request.  Is there anyway to get Delphi XE to generate a SOAP request with the  xmlns attribute set to blank as it used to be?
0
Kelly
10/21/2010 4:33:36 PM
embarcadero.delphi.webservices 976 articles. 0 followers. Follow

5 Replies
2584 Views

Similar Articles

[PageSpeed] 40

Hello,


> In trying to upgrade our web service client to Delphi XE we have now get a 
> web service error of Invalid Format.
>
> When we examine the SOAP request we see the following differences from 
> Delphi 7 vs Delphi XE
>
> In Delphi 7 we get
>
> <SomeStuff xmlns="" xsi:nil="true" />
>
> In Delphi XE we get
>
> <SomeStuff xsi:nil="true" />
>
> We have narrowed the failure down to these differences in the client 
> request.  Is there anyway to get Delphi XE to generate a SOAP request with 
> the  xmlns attribute set to blank as it used to be?


In general XE offers more flexibility on how to encoding the XML.  For a 
non-nil node one can tag an element/parameter as unqualified to have the 
xmlns=""' attribute using the IS_UNQL flag. I would need to know more about 
'SomeStuff'. Is it a parameter to a function or a property of a class. And 
does the service use literal encoding? Without this information I can't 
really say how to make the runtime do what you're after [other then tweak 
the generated XML in the OnBeforeExecute event but I recommend this approach 
as a last resort]; The runtime should understand what the service expects 
and generate the correct request. So, if you could point me to a WSDL/Schema 
or even post the binding generated by the importer, that would help.

Cheers,

Bruneau
0
Jean
10/22/2010 2:51:22 AM
> {quote:title=Jean-Marie Babet wrote:}{quote}
> Hello,
> 
> 
> > In trying to upgrade our web service client to Delphi XE we have now get a 
> > web service error of Invalid Format.
> >
> > When we examine the SOAP request we see the following differences from 
> > Delphi 7 vs Delphi XE
> >
> > In Delphi 7 we get
> >
> > <SomeStuff xmlns="" xsi:nil="true" />
> >
> > In Delphi XE we get
> >
> > <SomeStuff xsi:nil="true" />
> >
> > We have narrowed the failure down to these differences in the client 
> > request.  Is there anyway to get Delphi XE to generate a SOAP request with 
> > the  xmlns attribute set to blank as it used to be?
> 
> 
> In general XE offers more flexibility on how to encoding the XML.  For a 
> non-nil node one can tag an element/parameter as unqualified to have the 
> xmlns=""' attribute using the IS_UNQL flag. I would need to know more about 
> 'SomeStuff'. Is it a parameter to a function or a property of a class. And 
> does the service use literal encoding? Without this information I can't 
> really say how to make the runtime do what you're after [other then tweak 
> the generated XML in the OnBeforeExecute event but I recommend this approach 
> as a last resort]; The runtime should understand what the service expects 
> and generate the correct request. So, if you could point me to a WSDL/Schema 
> or even post the binding generated by the importer, that would help.
> 
> Cheers,
> 
> Bruneau
0
Kelly
10/26/2010 8:44:51 PM
> {quote:title=Kelly Sonderegger wrote:}{quote}
> > {quote:title=Jean-Marie Babet wrote:}{quote}
> > Hello,
> > 
> > 
> > > In trying to upgrade our web service client to Delphi XE we have now get a 
> > > web service error of Invalid Format.
> > >
> > > When we examine the SOAP request we see the following differences from 
> > > Delphi 7 vs Delphi XE
> > >
> > > In Delphi 7 we get
> > >
> > > <SomeStuff xmlns="" xsi:nil="true" />
> > >
> > > In Delphi XE we get
> > >
> > > <SomeStuff xsi:nil="true" />
> > >
> > > We have narrowed the failure down to these differences in the client 
> > > request.  Is there anyway to get Delphi XE to generate a SOAP request with 
> > > the  xmlns attribute set to blank as it used to be?
> > 
> > 
> > In general XE offers more flexibility on how to encoding the XML.  For a 
> > non-nil node one can tag an element/parameter as unqualified to have the 
> > xmlns=""' attribute using the IS_UNQL flag. I would need to know more about 
> > 'SomeStuff'. Is it a parameter to a function or a property of a class. And 
> > does the service use literal encoding? Without this information I can't 
> > really say how to make the runtime do what you're after [other then tweak 
> > the generated XML in the OnBeforeExecute event but I recommend this approach 
> > as a last resort]; The runtime should understand what the service expects 
> > and generate the correct request. So, if you could point me to a WSDL/Schema 
> > or even post the binding generated by the importer, that would help.
> > 
> > Cheers,
> > 
> > Bruneau

Hi Bruneau,

Sorry to be so late in responding.  I had to reproduce the problem on my own machine.

So currently the following type of request fails
 
<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>
   <CheckInsertCustomer xmln="http://mycompany.com/User>
       <c>
            <CustomerSetupFee xsi:nil="true" />
       </c>
    </CheckInsertCustomer>
<SOAP-ENV:Body>
</SOAP-ENV:Envelope>

However this type of request succeeds 
<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>
   <CheckInsertCustomer xmln="http://mycompany.com/User>
       <c>
            <CustomerSetupFee xmlns="" xsi:nil="true" />
       </c>
    </CheckInsertCustomer>
<SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The only difference being that xmln="" is set as an attribute on CustomerSetupFee

If the IS_UNQL flag is what I use then how would I use it?  Is there a way to set it up when generating the SOAP code?

Thanks Bruneau,
Kelly
0
Kelly
10/26/2010 9:03:00 PM
Hello,


> Sorry to be so late in responding.  I had to reproduce the problem on my 
> own machine.

No need to apologize: I've been away from the forum working in another area.


> So currently the following type of request fails
>
> <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>
>   <CheckInsertCustomer xmln="http://mycompany.com/User>
>       <c>
>            <CustomerSetupFee xsi:nil="true" />
>       </c>
>    </CheckInsertCustomer>
> <SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> However this type of request succeeds
> <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>
>   <CheckInsertCustomer xmln="http://mycompany.com/User>
>       <c>
>            <CustomerSetupFee xmlns="" xsi:nil="true" />
>       </c>
>    </CheckInsertCustomer>
> <SOAP-ENV:Body>
> </SOAP-ENV:Envelope>

OK, so the service expects the element to be unqualified. I'd like to see 
the binding that Delphi generated for the call to CheckInsertCustomer. Is it 
something like this:

{Code}

type
  TCustomerSetupFee = class(TRemotable)
  end;

  CheckInsertCustomerParam = class(TRemotable)
  private
    FCustomerSetupFee: TCustomerSetupFee;
    FCustomerSetupFee_specified: Boolean;
    procedure SetCustomerSetupFee(Index: Integer; A: TCustomerSetupFee);
  published
    property CustomerSetupFee: TCustomerSetupFee
                               Index (IS_NLBL or IS_UNQL)
                               read FCustomerSetupFee
                               write SetCustomerSetupFee
                               stored FCustomerSetupFee_specified;
  end;

  IService = interface(IInvokable)
  ['{91CD7287-EA4F-4FA9-9C1C-6C8A78AE84E5}']
    function CheckInsertCustomer(c: CheckInsertCustomerParam): string; 
stdcall;
  end;
{code}

The key above is the IS_NLBL and IS_UNQL flag. If these two are set, the XML 
generated by Delphi SOAP will be:


{code}
<?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>
    <CheckInsertCustomer xmlns="urn:test_namespace">
      <c>
        <CustomerSetupFee xmlns="" xsi:nil="true"/>
      </c>
    </CheckInsertCustomer>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
{code}



>
> The only difference being that xmln="" is set as an attribute on 
> CustomerSetupFee
>
> If the IS_UNQL flag is what I use then how would I use it?  Is there a way 
> to set it up when generating the SOAP code?


See the above sample. However, this may not apply to you if that's not the 
code the importer generated for you. I you cannot post the code Delphi 
generated for you, please, do email me the binding at bbabet at embarcadero 
dot com.

Cheers,

Bruneau
0
Jean
11/8/2010 1:21:21 AM
Hello,

Thanks for the WSDL. I'll need to double-check this later but the WSDL you 
sent contains two schemas and they both say that the elements default to 
qualified. As in:

{code}
<s:schema elementFormDefault="qualified"
   .....
{code}


So, this means that all elements are qualified by default and that an 
unqualified element must explicitly override the default with a 
'form="unqualified"' attribute. However, I find no such attributes in the 
schema itself. So I don't really understand why the Service expects 
unqualified nil elements.

I can update the wsdl/schema to specify unqualified elements (by adding the 
`nillable="true"` attribute to the element) and Delphi SOAP will then 
generate unqualified elements; but the problem is that it will generate 
unqualified elements all the time: not just for nil elements.

Is that going to be OK with the Service when the element's value is not nil? 
I'll send you a copy of the binding generated with a .WSDL updated to 
specify unqualified elements. And maybe that will work with the Service.

I will re-read the spec on nil elements 
(http://www.w3.org/TR/xmlschema-0/#Nils) to make sure I'm not missing 
anything.

Cheers,

Bruneau
0
Jean
11/8/2010 10:40:00 PM
Reply: