EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Triying

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
#31876
Posted: 01/13/2015 04:45:44
by Pep Palotes (Basic support level)
Joined: 01/13/2015
Posts: 5

I'm testing your software to consume the webservice of the Spanish tax office and have created a xml containing a securesoap request according to its xmlblacbox example \ securesoap, So far so good but in his xmlblacbox example \ soapclient I get not properly charging the request in the TElXMLSOAPClient component because when sending tells me that is not signed but the xml if this signature
Code
          FXMLDocument := TElXMLDOMDocument.Create;
          FXMLDocument.LoadFromFile(extractfilepath(application.exename) + 'requestsoap.xml');
          FSOAPClient := TElXMLSOAPClient.Create(nil);
          try
            FSOAPClient.SOAPPrefix := 'soap';
            FSOAPClient.SOAPVersion := SOAP_v1_2;
            FSOAPClient.OperationName := 'enviarFactura';
            FSOAPClient.OperationNamespaceURI := 'https://se-face-webservice.redsara.es';
            FSOAPClient.MessageNamespaces.Clear;

            FSOAPClient.HTTPClient := HTTPSClient;
            FSOAPClient.URL := 'https://se-face-webservice.redsara.es/sspp';
            FSOAPClient.SOAPAction := 'https://se-face-webservice.redsara.es/sspp/enviarFactura';
            fsoapclient.GenerateMessage;
            fsoapclient.SOAPMessage.LoadFromXML(FXMLDocument);
            FSOAPClient.SendMessage;
          except
            on E: Exception do
            begin
              MessageDlg('Failed to send SOAP message: ' + E.Message, mtError, [mbOk], 0);
            end;
          end;
#31878
Posted: 01/13/2015 05:18:10
by Dmytro Bogatskyy (EldoS Corp.)

Thank you for contacting us.

Quote

fsoapclient.GenerateMessage;
fsoapclient.SOAPMessage.LoadFromXML(FXMLDocument);

If you want to override a SOAP message created by TElXMLSOAPClient component, you would need to use a following code:
Code
FSOAPClient.GenerateMessage;
FSOAPClient.XMLDocument.LoadFromFile(extractfilepath(application.exename) + 'requestsoap.xml');
FSOAPClient.SOAPMessage.LoadFromXML(FSOAPClient.XMLDocument); // reload a SOAP message if needed
FSOAPClient.SendMessage;


By the way, why do you need to load a message from file? You can sign a newly created message in the same way as in SecureSOAP sample, for example:
Code
FSOAPClient.GenerateMessage;
Handler := TElXMLWSSSignatureHandler.Create(nil);
FSOAPClient.SOAPMessage.AddSignature(Handler, true);
Handler.AddReference(FSOAPClient.SOAPMessage.Envelope.Body, true);
Handler.Sign(Cert, wecInBinarySecurityToken);
#31880
Posted: 01/13/2015 06:03:09
by Pep Palotes (Basic support level)
Joined: 01/13/2015
Posts: 5

I selected the first suggested change and replaced the code and I keep getting the same message
Certificate validation handler is not assigned.

When loading the xml should not automatically updated signature?
Code
          FXMLDocument := TElXMLDOMDocument.Create;
          FXMLDocument.LoadFromFile(extractfilepath(application.exename) + 'requestsoap.xml');
          FSOAPClient := TElXMLSOAPClient.Create(nil);
          try
            FSOAPClient.SOAPPrefix := 'soap';
            FSOAPClient.SOAPVersion := SOAP_v1_2;
            FSOAPClient.OperationName := 'enviarFactura';
            FSOAPClient.OperationNamespaceURI := 'https://se-face-webservice.redsara.es';
            FSOAPClient.MessageNamespaces.Clear;

            FSOAPClient.HTTPClient := HTTPSClient;
            FSOAPClient.URL := 'https://se-face-webservice.redsara.es/sspp';
            FSOAPClient.SOAPAction := 'https://se-face-webservice.redsara.es/sspp/enviarFactura';
            fsoapclient.GenerateMessage;
            FSOAPClient.XMLDocument.LoadFromFile(extractfilepath(application.exename) + 'requestsoap.xml');
            FSOAPClient.SOAPMessage.LoadFromXML(FSOAPClient.XMLDocument); // reload a SOAP message if needed
            FSOAPClient.SendMessage;
          except
            on E: Exception do
            begin
              MessageDlg('Failed to send SOAP message: ' + E.Message, mtError, [mbOk], 0);
            end;
          end;
#31881
Posted: 01/13/2015 06:07:03
by Eugene Mayevski (EldoS Corp.)

Quote
Pep Palotes wrote:
I selected the first suggested change and replaced the code and I keep getting the same message Certificate validation handler is not assigned.


You MUST handle OnCertificateValidate event. Please check documentation for details.


Sincerely yours
Eugene Mayevski
#31882
Posted: 01/13/2015 06:29:01
by Pep Palotes (Basic support level)
Joined: 01/13/2015
Posts: 5

Incredible speed of their responses, I had not gone anywhere ..

I have validated the signature server using
Code
  validate:=true;
in event HTTPSClientCertificateValidate

but now I get the error 100354
Communication failed for unidentified reason During sending or retrieving request response.
Any ideas?

Requestsoap.xml not get attach file, put it in DropBox
https://app.box.com/s/2situi3trq94tntsza4y
Thanks,
#31883
Posted: 01/13/2015 06:31:57
by Eugene Mayevski (EldoS Corp.)

Try to connect to the server using the HTTPGet sample from <SecureBlackbox>\Samples\<language>\HTTPBlackbox\Client folder. Just request something from the server.

This sample returns a log of what is sent and what is received. Let's analyze the log.


Sincerely yours
Eugene Mayevski
#31888
Posted: 01/13/2015 07:17:01
by Pep Palotes (Basic support level)
Joined: 01/13/2015
Posts: 5

Log:

Headers sent:
POST /sspp HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8; action=https://se-face-webservice.redsara.es/sspp/enviarFactura
Host: se-face-webservice.redsara.es
User-Agent: SecureBlackbox
Accept-Encoding: gzip, deflate
Connection: Close
Content-Length: 17209

No errors!!! any idea?
#31889
Posted: 01/13/2015 07:32:22
by Eugene Mayevski (EldoS Corp.)

This is not a log of the sample that I suggested you to check.


Sincerely yours
Eugene Mayevski
#31905
Posted: 01/14/2015 02:40:01
by Pep Palotes (Basic support level)
Joined: 01/13/2015
Posts: 5

The webservice needs to be signed and if I do in the example gives me error and the log is

Headers sent:

GET / sspp / enviarFactura: 443 / HTTP / 1.1
Host: se-face-webservice.redsara.es
User-Agent: SecureBlackbox
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

Exception: Connection failed due to error (75,784) (error code is 75784)

I've tried to replicate the log is generated by the example in my program,
Would you like to do something else?
Thanks
#31908
Posted: 01/14/2015 02:58:05
by Eugene Mayevski (EldoS Corp.)

Well, it seems that your server forcefully closes socket connection instead of replying with the HTTP response code in case it doesn't like anything in the sent data.

This is the answer to your question about error 100354. The server is buggy, that's it.

Now back to your problem. What you can start with is prepare SOAP request with somethird-party tool and POST the prepared data to the server using TElHTTPSClient's Post() method. See if this works. If it doesn't, then we need to find out what's wrong with the server first. If this works, then we can go further by making your SOAP request identical to what the third-party tool generates.


Sincerely yours
Eugene Mayevski
Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.

Reply

Statistics

Topic viewed 1224 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!