Invalid parameter : AProtocolData

165 views
Skip to first unread message

Md. Shariful Alam Khan

unread,
Dec 7, 2015, 4:36:35 PM12/7/15
to WST-LIST
What shall I put to avoid this error? This is what I did:
TMerchantWebServicesPortType_Proxy.Create('MerchantWebServices', 'v1', '');

Inoussa OUEDRAOGO

unread,
Dec 8, 2015, 8:06:00 AM12/8/15
to wst-...@googlegroups.com
2015-12-07 21:36 UTC, Md. Shariful Alam Khan <shariful...@gmail.com>:
> What shall I put to avoid this error? This is what I did:
> TMerchantWebServicesPortType_Proxy.Create('MerchantWebServices', 'v1', '');

The proxy unit generated by ws_helper contains a helper function to
easily create an instance, for your sample it may be called
"wst_CreateInstance_MerchantWebServicesPortType".
To use the proxy's constructor, you will have to specify the
serialization and transport protocols details, such as

TMerchantWebServicesPortType_Proxy.Create('MerchantWebServices',
'SOAP:', 'http:Address=http://www.your.service.address.com');

See [1] for more info.

Please note that you have to include, in you uses list, the specific
unit for each protocol you will be using, such as :
* soap_formatter for SOAP support,
* fpc_http_protocol for FPC native HTTP client protocol; For
transport protocols, you have to explicitly register the format by
calling the registering function declared in the supporting unit,
FPC_RegisterHTTP_Transport for example.

[1] http://wiki.lazarus.freepascal.org/Web_Service_Toolkit

--
Inoussa O.

Md. Shariful Alam Khan

unread,
Dec 8, 2015, 8:38:11 AM12/8/15
to WST-LIST
After adding soap_formatter, AProtocolData error gone. Now I am getting Invalid Parameter : ATransportData. Which unit do I have to use?

It is better to mention in the exception to add appropriate unit.

Inoussa OUEDRAOGO

unread,
Dec 8, 2015, 1:54:42 PM12/8/15
to wst-...@googlegroups.com
2015-12-08 13:38 UTC, Md. Shariful Alam Khan <shariful...@gmail.com>:
> After adding soap_formatter, AProtocolData error gone. Now I am getting
> Invalid Parameter : ATransportData. Which unit do I have to use?

* If you are using FPC:
use "fpc_http_protocol" for http,
make the call "FPC_RegisterHTTP_Transport();" once in you program

* If you are using DELPHI:
use "indy_http_protocol" for http,
make the call "INDY_RegisterHTTP_Transport();" once in you program

Please make sure your protocol parameters are correct.



--
Inoussa O.

Md. Shariful Alam Khan

unread,
Dec 8, 2015, 1:59:41 PM12/8/15
to WST-LIST
Is there any HTTPS transport available? I need TLS v1.2.

Inoussa OUEDRAOGO

unread,
Dec 8, 2015, 3:01:58 PM12/8/15
to wst-...@googlegroups.com
2015-12-08 18:59 UTC, Md. Shariful Alam Khan <shariful...@gmail.com>:
> Is there any HTTPS transport available? I need TLS v1.2.

Yes.
Note that in that case, you will need to use Synapse or Indy(I'm sure
for Indy, but I think it has support for HTTPS) through OpenSSL. I'm
sure you noted that it will be
* synapse_http_protocol unit to register with
"SYNAPSE_RegisterHTTP_Transport();" . Please see the synapse website
for how to enable HTTPS support,

* indy_http_protocol unit to register with
"INDY_RegisterHTTP_Transport();" . Please see the Indy
website/documentation for how to enable HTTPS support.

NB: Please see:
[1] http://wiki.freepascal.org/Synapse#SSL.2FTLS_support
[2] http://synapse.ararat.cz/doku.php/public:howto:sslplugin

--
Inoussa O.

Md. Shariful Alam Khan

unread,
Dec 8, 2015, 4:16:05 PM12/8/15
to WST-LIST
Thanks.

I added synapse and ssl_openssl unit on my project. On execution I am getting following error:
Exception at 000000000047CB8D: ETransportExecption:
HTTP Request to https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1 failed.Result code: 500, message: "".
Its must be HTTPS request. How can I do that? This is what I did:

procedure TForm1.Button1Click(Sender: TObject);
var
  send: SendTranRequest;
  me: Merc;
  tr: TranData;
  //mt : MerchantWebServicesPortType;
begin
  send := SendTranRequest.Create;
  me := Merc.Create;
  me.id := '777xxxxxxx';
  me.regKey := 'JExxxxxxxxxxx;
  send.merc := me;
  tr := TranData.Create;
  tr.tranNr := '1';
  send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__0;
  SYNAPSE_RegisterHTTP_Transport;
  Memo1.Text := string(wst_CreateInstance_MerchantWebServicesPortType().SendTran(send));
end;

Inoussa OUEDRAOGO

unread,
Dec 9, 2015, 3:17:52 AM12/9/15
to wst-...@googlegroups.com
2015-12-08 21:16 UTC, Md. Shariful Alam Khan <shariful...@gmail.com>:
> Thanks.
>
> I added synapse and ssl_openssl unit on my project. On execution I am
> getting following error:
> Exception at 000000000047CB8D: ETransportExecption:
> HTTP Request to
> https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1
>
> failed.Result code: 500, message: "".
> Its must be HTTPS request. How can I do that? This is what I did:

Did you put the OpenSSL libraries to your application directory? and
make sure the OpenSSL libraries load actually ?


--
Inoussa O.

Md. Shariful Alam Khan

unread,
Dec 9, 2015, 3:20:56 AM12/9/15
to WST-LIST
I am doing it in CentOS 6 latest version. How to load OpenSSL Library and where to find it?

Inoussa OUEDRAOGO

unread,
Dec 9, 2015, 3:34:47 AM12/9/15
to wst-...@googlegroups.com
2015-12-09 8:20 UTC, Md. Shariful Alam Khan <shariful...@gmail.com>:
> I am doing it in CentOS 6 latest version. How to load OpenSSL Library and
> where to find it?

I have no practice with CentOS, but on Linux there are certainly
OpenSSL packages that may be installed in the system.

But that is a transport problem, if you are sure that the problem is
related to HTTPS (better prove it than guess it, you have all the
sources, you can then debug it). Please make sure to understand how
Synapse HTTPS support works in a simple program for example to
download a HTTPS web page and apply this understanding to fix the
problem with the web service.

--
Inoussa O.

Md. Shariful Alam Khan

unread,
Dec 10, 2015, 3:33:57 AM12/10/15
to WST-LIST
Have successfully bypass the OpenSSL. Now I am getting following error:
Exception at 00000000005029AE: EXMLReadError:
In 'stream:' (line 1 pos 1345): Unmatching element end tag (expected "</HR>").

Following is my code:
procedure Execute;
var
    vGetMerchant: UnicodeString;

    send: SendTranRequest;
    me: Merc;
    tr: TranData;
    vcard : Card;

begin
    send := SendTranRequest.Create;
    me := Merc.Create;
    me.id := UnicodeString(GatewayID);
    me.regKey := UnicodeString(RegKey);

    send.merc := me;
    tr := TranData.Create;
    tr.tranNr := '1';
    case trancode of
      '0': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__0;
      '1': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__1;
      '2': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__2;
      '3': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__3;
      '4': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__4;
      '5': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__5;
      '6': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__6;
      '7': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__7;
      '9': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__9;
      '10': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__10;
      '11': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__11;
      '12': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__12;
      '13': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__13;
      '14': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__14;
      '15': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__15;
      '17': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__16;
      '18': send.tranCode := SendTranRequest_tranCode_Type.SendTranRequest_tranCode_Type__18;
    end;
    vcard := Card.Create;
    vcard.pan := UnicodeString(AccountNumber);
    vcard.sec := UnicodeString(CVV2);
    vcard.xprDt := UnicodeString(ExpirationDate);
    send.card := vcard;
    send.reqAmt := UnicodeString(Amount);
    SYNAPSE_RegisterHTTP_Transport;
    vGetMerchant := UnicodeString(wst_CreateInstance_MerchantWebServicesPortType('SOAP:',
      'HTTP:Address=https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1',
      'https://ws.cert.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1').SendTran(send));
    WriteLn(vGetMerchant);
end;

Can you please help?

Inoussa OUEDRAOGO

unread,
Dec 11, 2015, 2:38:47 AM12/11/15
to wst-list


2015-12-10 8:33 GMT+00:00 Md. Shariful Alam Khan <shariful...@gmail.com>:
Have successfully bypass the OpenSSL. Now I am getting following error:
Exception at 00000000005029AE: EXMLReadError:
In 'stream:' (line 1 pos 1345): Unmatching element end tag (expected "</HR>").

It seams this is a pure xml content problem.
You may see the exchanged messages between your client and the server following the steps described at [1].

[1] https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/wst-list/LZw3GdRmkf4

--
Inoussa O.

Md. Shariful Alam Khan

unread,
Dec 11, 2015, 3:37:03 AM12/11/15
to WST-LIST
  const
    TRANSPORT_STRING = 'HTTP:address=%s;FilterString=LogFilter,OutputDir=%s';
HTTP:address=https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1;FilterString=LogFilter,OutputDir=/home/mouri/merchant/
Exception at 000000000042A333: EFCreateError:
Unable to create file "/request.log".
  const
    TRANSPORT_STRING = 'HTTP:address=%s;FilterString=LogFilter,OutputDir>%s';
HTTP:address=https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1;FilterString=LogFilter,OutputDir>/home/mouri/merchant/
Exception at 000000000042A343: EFCreateError:
Unable to create file "/home/mouri/merchant/address=https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1/request.log"

  const
    TRANSPORT_STRING = 'HTTP:address=%s;FilterString=LogFilter,OutputDir=%s>';
HTTP:address=https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1;FilterString=LogFilter,OutputDir=/home/mouri/merchant/>
Exception at 000000000042A343: EFCreateError:
Unable to create file "/request.log".

    ftransportstring := Format(TRANSPORT_STRING,
      ['https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1',
      ExtractFilePath(ParamStr(0))]);

also tried deleting last path delimeter of ExtractFilePath. Which will be the actual string?

Inoussa OUEDRAOGO

unread,
Dec 11, 2015, 2:21:38 PM12/11/15
to wst-...@googlegroups.com
2015-12-11 8:37 UTC, Md. Shariful Alam Khan <shariful...@gmail.com>:
> const
> *TRANSPORT_STRING =
> 'HTTP:address=%s;FilterString=LogFilter,OutputDir=%s';*
> HTTP:address=https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1;FilterString=LogFilter,OutputDir=/home/mouri/merchant/
> Exception at 000000000042A333: EFCreateError:
> Unable to create file "/request.log".

I just this[2]. And got "Unable to create file
"/home/mouri/merchant/request.log"", yes I am on Windows, but the file
name is correct, please try using this address[1], directly, without
using format.

[1] HTTP:address=https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1;FilterString=LogFilter,OutputDir>/home/mouri/merchant/

[2]
program Project1;
uses
Classes, fpc_http_protocol, service_intf, client_filters;

const
TRANSPORT_STRING =
'HTTP:address=https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1;FilterString=LogFilter,OutputDir>/home/mouri/merchant/';
var
t : ITransport;
s : TMemoryStream;
z : AnsiString;
begin
RegisterLogFilter();
FPC_RegisterHTTP_Transport();
if GetTransportRegistry().Find(TRANSPORT_STRING,t) then begin
WriteLn('OK --- 1');
s := TMemoryStream.Create();
try
z := 'Hello WST.';
s.Write(z[1],Length(z));
s.Position := 0;
t.SendAndReceive(s,s);
finally
s.Free();
end;
end;
end.


--
Inoussa O.

Md. Shariful Alam Khan

unread,
Dec 11, 2015, 2:37:27 PM12/11/15
to WST-LIST
I did this:
but on debug output directory set as /home/mouri/merchant/address=https://ws.cert.transactionexpress.com:443/portal/merchantframework/MerchantWebServices-v1

Is there way to set Output path separately?

Md. Shariful Alam Khan

unread,
Dec 11, 2015, 2:57:39 PM12/11/15
to WST-LIST
I modified client_filter.pas as following in SaveToFile method
procedure TLogFilter.SaveToFile(
  const AData     : TByteDynArray;
  const AFileName : string
);
var
  locFileName : string;
  locStream : TMemoryStream;
begin
  OutputDir := Copy(OutputDir, 1, Pos('=', OutputDir));
  OutputDir := Copy(OutputDir, 1, LastDelimiter(IncludeLeadingPathDelimiter(''), OutputDir) - 1);
  if OutputDir = '' then
    OutputDir := fTempOutputDir; //set as private
  locFileName := IncludeTrailingPathDelimiter(OutputDir) + AFileName;
  locStream := TMemoryStream.Create();
  try
    if (Length(AData) > 0) then
      locStream.Write(AData[0],Length(AData));
    locStream.SaveToFile(locFileName);
    fTempOutputDir := OutputDir;
  finally
    locStream.Free();
  end;
end;

this way its working.
Reply all
Reply to author
Forward
0 new messages