Delphi wrapping TXMLData in SOAP request with <schema> tag

扶醉桌前 提交于 2019-12-06 09:56:39

It looks like Delphi looks at the <MyXML> and thinks

"this piece of XML does not have an associated namespace, so I just throw it in the XMLSchema namespace - and hey!, this namespace is not yet in the namespaces of the SOAP message, so I will add it to make the SOAP server happy!"

  • note that in your example <MyXML> is not a well-formed XML document. It is only the opening 'tag'.

I don't know the TXMLData details but it might support namespaces. Maybe you can add a namespace declaration to the XML document, and then the SOAP request will look better.


SOAP request body example (from Wikipedia):

<s:Body>
    <m:TitleInDatabase xmlns:m="http://www.lecture-db.de/soap">
        DOM, SAX and SOAP
    </m:TitleInDatabase>
</s:Body>

This shows that a SOAP body can be a 'stand-alone' XML document with the namespace declaration in the root element (not a separate outer element as in your case).

Solved.

Delphi was mapping the webservice as:

RequestData = TXMLData;

MyService = interface(IInvokable)
  ['{5D2D1DD8-AE56-AD82-FC59-8669C576E1AF}']
  function ExecuteRequest(const RequestData: RequestData): RequestResult; stdcall;
end;

Changing:

RequestData = TXMLData;

to

RequestData = class(TXMLData);

Solved the issue.

Now delphi is using the "RequestData" as the top node of the XML in the Body of the request, instead of adding a schema tag.

Now the call is generating something like this:

<RequestData>[MyXML]</RequestData>

Which is what I need to send.

It sounds like you have a non-compliant web service that you have to hit, but the SOAP library is getting in the way. So you may need to resort to the "brute force" approach of replacing the request in the OnBeforeExecute handler. Before doing that though, I'd try consuming the service WSDL with SoapUI. See if a SoapUI request is accepted by the service. If that doesn't work without severe editing of the request, then the above approach is justified.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!