Consume WebService in SOAP with HTTPRIO in DELPHI

1

I'm having a difficulty with a request via webservice / soap . I'm trying to feed a function from a WSDL from Vtex through Delphi and it always returns me that a value has not been filled.

Code of my function Insert Field

function TIntegracaoVtex.InserirCampo : Boolean;
var
  funcao : ProductEspecificationInsertByFieldId;
  funcaoResposta: ProductEspecificationInsertByFieldIdResponse;
  valor  : arrayOfString;
begin
  Result := False;
  try
  funcao := ProductEspecificationInsertByFieldId.Create;

  SetLength(valor, 1);
  valor[0]  := '16GB';

  funcao.idProduct   := 11;
  funcao.fieldId     := 23;
  funcao.fieldValues := valor;


  funcaoResposta := ProductEspecificationInsertByFieldIdResponse.Create;
  servico := GetIService(False, 'http://webservice-'+loja+'.vtexcommerce.com.br/AdminWebService/Service.svc', HTTPRIO1);
  servico.ProductEspecificationInsertByFieldId(funcao);

  funcaoResposta := servico.ProductEspecificationInsertByFieldId(funcao);

  Result := True;
  except
    Result := False;
  end;

WebService function in SOAP, imported from VTEX environment

function  ProductEspecificationInsertByFieldId(const parameters: ProductEspecificationInsertByFieldId): ProductEspecificationInsertByFieldIdResponse; stdcall;

Class received as parameter to feed function

ProductEspecificationInsertByFieldId = class(TRemotable)
  private
    FidProduct: Integer;
    FidProduct_Specified: boolean;
    FfieldId: Integer;
    FfieldId_Specified: boolean;
    FfieldValues: ArrayOfstring;
    FfieldValues_Specified: boolean;
    procedure SetidProduct(Index: Integer; const AInteger: Integer);
    function  idProduct_Specified(Index: Integer): boolean;
    procedure SetfieldId(Index: Integer; const AInteger: Integer);
    function  fieldId_Specified(Index: Integer): boolean;
    procedure SetfieldValues(Index: Integer; const AArrayOfstring: ArrayOfstring);
    function  fieldValues_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
  published
    property idProduct:   Integer        Index (IS_OPTN) read FidProduct write SetidProduct stored idProduct_Specified;
    property fieldId:     Integer        Index (IS_OPTN) read FfieldId write SetfieldId stored fieldId_Specified;
    property fieldValues: ArrayOfstring  Index (IS_OPTN or IS_NLBL) read FfieldValues write SetfieldValues stored fieldValues_Specified;
  end;

Return of the function obtained by SOAPResponse

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <s:Fault>
         <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
         <faultstring xml:lang="pt-BR">Value cannot be null.&amp;#xD;
Parameter name: Nenhum valor de especificação foi passado.</faultstring>
         <detail>
            <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
               <HelpLink i:nil="true" />
               <InnerException i:nil="true" />
               <Message>Value cannot be null.&amp;#xD;
Parameter name: Nenhum valor de especificação foi passado.</Message>
               <StackTrace>at Vtex.Commerce.WebApps.AdminWcfService.Service.ProductEspecificationInsertByFieldId(Int32 idProduct, Int32 fieldId, List'1 fieldValues) in D:\BuildAgent\workaf720f163d9625\src\Web Applications\Vtex.Commerce.WebApps.AdminWcfService\Service.svc.cs:line 3873&amp;#xD;
   at SyncInvokeProductEspecificationInsertByFieldId(Object , Object[] , Object[] )&amp;#xD;
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)&amp;#xD;
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)&amp;#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)&amp;#xD;
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)&amp;#xD;
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
               <Type>System.ArgumentNullException</Type>
            </ExceptionDetail>
         </detail>
      </s:Fault>
   </s:Body>
</s:Envelope>
    
asked by anonymous 28.08.2017 / 19:38

1 answer

0

In my VTEX integration, I use the following form:

var
  objProduto: ProductInsertUpdate;

begin
    objProduto := ProductInsertUpdate.Create;
    objProduto.productVO := ProductDTO2.Create;

    with objProduto.productVO do
    begin
        Id := 23;
        // ... demais dados
    end;

    GetIService.ProductInsertUpdate(objProduto);
end;

Try something with the template above.

    
01.09.2017 / 22:22