Consume Webservice in SOAP with HTTPRIO in DELPHI

Asked

Viewed 2,430 times

2

I’m having a little trouble with a request via webservice/Soap. I’m trying to feed a function of a WSDL of Vtex through the Delphi and it always returns to me that a value has not been filled in.

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 environment VTEX

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

Class received as parameter to feed the 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 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\work\67af720f163d9625\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>

1 answer

0


In my VTEX integration, I use as follows:

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 model above.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.