webservice rest to receive an xml in delphi

3

Good afternoon. A client wants to send me an .xml file
I created a DataSnap Rest Application project. I implemented the method as follows for JSON

function TFo_SM_Fornecedor.updateFornecedor(TObjJson: TJsonObject): TJsonValue;
Var
  Fornecedor: TFornecedor;
begin
  Fornecedor := TJson.JsonToObject<TFornecedor>(TObjJson.toJson);
  Try
    Result := TJSONString.Create('Incluindo Cliente..: ' +
      Fornecedor.tx_razaosocial);
  Finally
    FreeandNil(Fornecedor);
  End;    
end;

To receive a TJsonObject type works perfectly. But as I said at the beginning I will receive an .xml. I have already made several delphi codes to receive an xml and put the values in the base, but it is the first time I have to develop a server and I am without a direction. Can any of my colleagues give me a light? At first (for a few days now) I'm trying to change the line parameter

  

function TFo_SM_Folder.updateSupport (TObjJson: TJsonObject):

for something like

  

function TFo_SM_Provider.updateSupport (XML_files:   TStringTream):

But I'm unsuccessful. If any of you can give me a light, thank you.

    
asked by anonymous 25.06.2018 / 21:22

1 answer

0

I do not think I need to change the parameter, you could get xml as a String without problems, just identify a specific json field ...

I think of something sent to you as:

[
  {
    "xml": "todo xml aqui"
  }
]

Your function would receive a simple json and would test if the key is "xml" treat as xml, if it does not continue doing what it already does ...

This I have implemented and works perfectly for various file formats and my API.

To send me an image I request that it be a String, that is, a base64, to send me an MP3, send me a String, the requestor converts to TStringTream and sends me the bytes in String.

On my side I only recognize the key.

    
26.06.2018 / 15:38