i am currently writing a web service client in delphi 7 (service itself is in c#). everything seems to be working just fine. when i run a fiddler to look how does the xml going from my client app looks like i noticed that is looks different when i write the "same" client app in c#. Below are two xml`s
one that goes from a Delphi 7 app
<?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" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS2="http://tempuri.org/">
<NS1:SomeTagName xmlns:NS1="http://tempuri.org/">
<SomeID xsi:type="xsd:int">12345</SomeID>
<SomeStatus xsi:type="NS2:SomeStatusType">SOME_OK_STATUS</SomeStatus>
</NS1:SomeTagName>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
one that goes from c# app
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<SomeTagName xmlns="http://tempuri.org/">
<SomeID>12345</SomeID>
<SomeStatus>SOME_OK_STATUS</SomeStatus>
</SomeTagName>
</s:Body>
</s:Envelope>
i am not fluent in xml so i did some research and to this moment i am able to tell that
but what about the schema - not sure about that. There are some extra attributes in the Envelope or datatypes in SomeID and SomeStatus tags. But that came from service wsdl (i quess?!).
Final questions:
As for your second final question: these XML files can not be considered the same. Here's why:
The namespaces for the elements SomeID
and SomeStatus
are not the same. In the Delphi XML, no default namespace is ever specified anywhere in the XML. We only see the following namespaces:
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/"
xmlns:NS2="http://tempuri.org/"
xmlns:NS1="http://tempuri.org/"
Thus, the elements SomeID
and SomeStatus
are not in any namespace as they lack a namespace prefix.
Conversely, the XML from the c# app has the following namespaces
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="http://tempuri.org/"
As you can see, the second xmlns
attribute is a default namespace attribute, so the child elements SomeID
and SomeStatus
are in the "http://tempuri.org/" namespace. This means that these elements have different qualified names and are thus not equivalent.
(If I had to guess, I would reckon that the c# XML is correct and the Delphi XML has a bug. But I have no way to tell since the XSD for the SOAP standard to which you refer has no particular schema for the Body
.)
The Delphi XML has additional information about the type of SomeID
and SOME_OK_STATUS
. This may be useful to receivers since the SOAP standard "mandates no particular structure or interpretation of these elements, and provides no standard means for specifying the processing to be done" for elements inside the Body
. However, if the receiver already knows what to expect in these elements, these attributes may be unnecessary.
These are the main logical differences between the XML samples that I see.
As for the first final question, we would need to see the c# code to comment definitively on why the XML it produces looks like that. If XmlSerializer
was used for serialization, it will not output xsi:type
information for non-polymorphic fields unless forced to do so
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With