[Lazarus] Web-services

Ian Godman ian at gravytrain.co.uk
Mon Aug 6 11:37:17 CEST 2012


Hi

I have been having an issue with a "Hello World" web service.

The first issue was Lazarus throwing an error when processing the
response. This was chased down to  chunking. Having disabled the
chunking on the web-service no error is thrown. The trouble is now there
are no results either!

I have generated the Lazarus code using the Web Service Toolkit and
importing the WDSL (attached).

My code that makes use of the generated classes is:


program webservice;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes,
  { you can add units after this }
  hello, hello_proxy, soap_formatter, logger_extension,
  fpc_http_protocol;

{$R *.res}
var
  service : HelloWorldPortType;
  serviceText : hello_Type ;
  responce : helloResponse ;
begin
  FPC_RegisterHTTP_Transport();
  Register_hello_ServiceMetadata();
  WriteLn('Web Services Toolkit');
  WriteLn();
  service := wst_CreateInstance_HelloWorldPortType();
  serviceText:= hello_Type.create();
  serviceText.arg0:='fred_test';

  WriteLn( 'making service request' );
  responce:=service.hello(serviceText);
  if (responce=nil) then
     WriteLn( 'have NO service responce' )
  else
      WriteLn( 'have service responce' );
end.


The web service is written in Java and has a single string parameter
which is returned appended to the text "Hello ".

Example retuned (taken using SOAPUI)

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns1:helloResponse xmlns:ns1="http://example.org/">
         <ns1:return>Hello George</ns1:return>
      </ns1:helloResponse>
   </soap:Body>
</soap:Envelope>

With the chunking enabled I get an error referring to an unexpected
character before the '<' which suggests to me that the response is being
processed. But when the chunking is removed I no longer get the error
and the response is null.

Any ideas ?

I dont want to have to use C !


-------------- next part --------------
A non-text attachment was scrubbed...
Name: hello.wsdl
Type: application/x-wsdl
Size: 2234 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120806/dfa5b2c1/attachment-0002.bin>


More information about the Lazarus mailing list