Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Oh so very close
Sun, Jun 3 2012 2:24 AMPermanent Link

Jeff Newlin

Lightspeed

I'm completely new to all of this web service business but I did read this nice article that I found very helpful in getting an idea of what's going on and some nice basic info :

http://blogs.embarcadero.com/pawelglowacki/2008/12/18/38624

I did everything on Delphi 2007 but it worked all the way down and now I can call a webservice with a delphi vcl program - that's a big leap for me even though I'm just adding and subtracting.

So now I'm making the important leap and trying to accomplish the same thing using EWB and I'm running into some trouble. I think I may be confused on where to put things in the ServerRequest.RequestContent.

On the VCL program (delphi 2007) I used the WSDL Importer steps outlined in the article. It makes some constants that I think I must need to transfer into a server request :

{----------------From the VCL program using the WSDL Importer-------}
ISimpleCalculator = interface(IInvokable)
 ['{60CEE21F-CAFC-38B7-0AD9-FAA238B2690B}']
   function  Add(const a: Integer; const b: Integer): Integer; stdcall;
   function  Subtract(const a: Integer; const b: Integer): Integer; stdcall;
 end;

function GetISimpleCalculator(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ISimpleCalculator;

implementation
 uses SysUtils;

function GetISimpleCalculator(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ISimpleCalculator;
const
 defWSDL = 'http://localhost/delphi2007ws/delphi2007simplecalc.exe/wsdl/ISimpleCalculator';
 defURL  = 'http://localhost/delphi2007ws/delphi2007simplecalc.exe/soap/ISimpleCalculator';
 defSvc  = 'ISimpleCalculatorservice';
 defPrt  = 'ISimpleCalculatorPort';

etc...etc...etc
------------------------------------------------------------------------------------------------------

So I'm thinking I need to use these items in the ServerReqeust.RequestContent - this is what I'm trying :

  ServerRequest1.URL := 'http://localhost/delphi2007ws/delphi2007simplecalc.exe/soap/ISimpleCalculator' ;
  ServerRequest1.Method := rmPost;                        

  ServerRequest1.RequestContent.Clear;
  ServerRequest1.RequestContent.Add('<?xml version="1.0" encoding="utf-8"?>');
  ServerRequest1.RequestContent.Add('<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="'" name="http://schemas.xmlsoap.org/soap/envelope/">'">http://schemas.xmlsoap.org/soap/envelope/">');
  ServerRequest1.RequestContent.Add('<soap:Body>');
  ServerRequest1.RequestContent.Add('<Add xmlns="ISimpleCalculator">');
  ServerRequest1.RequestContent.Add('<a>'+ Edit1.Text + '</a>');
  ServerRequest1.RequestContent.Add('<b>' + Edit2.Text + '</b>');
  ServerRequest1.RequestContent.Add('</Add>');
  ServerRequest1.RequestContent.Add('</soap:Body>');
  ServerRequest1.RequestContent.Add('</soap:Envelope>');

  ServerRequest1.RequestHeaders.Clear;
  ServerRequest1.RequestHeaders.NameValueSeparator := '=';
  ServerRequest1.RequestHeaders.Add('Content-Type = text/xml; charset=utf-8');
  ServerRequest1.RequestHeaders.Add('Content-Length =' + IntToStr(Length(ServerRequest1.RequestContent.Text)));
  ServerRequest1.RequestHeaders.Add('SOAPAction = "ISimpleCalculatorservice/Add"');

  ServerRequest1.Execute;
----------------------------------------------------------------------------------------------------------------------

I get an application error that says :

Error executing request "http://localhost/delphi2007ws/delphi2007simplecalc.exe/soap/ISimpleCalculator" (Access is denied.)

Thanks for any light on this - so close but yet....

Jeff
Sun, Jun 3 2012 11:23 AMPermanent Link

Raul

Team Elevate Team Elevate

Jeff

I've personally found it's easier to just capture the traffic (assuming
you have a working client side app already which you do) and duplicate
the request details in EWB/Javascript type app - it's just plain XML
after all.

I personally use Fiddler (http://www.fiddler2.com/fiddler2/) but there
are other choices.

Start fiddler, run your vcl app and you should see the http request in
all its detail (as well as response) and then fill-in your server
request as you're doing.

Raul


On 6/3/2012 2:24 AM, Jeff Newlin wrote:
> Thanks for any light on this - so close but yet....
>
> Jeff
>
Mon, Jun 4 2012 4:55 AMPermanent Link

Jeff Newlin

Lightspeed

Thanks Raul! I tried out Fiddler and I can see things now. This will help me a lot.

But I can tell that it is giving me this error before it starts a session. However on my (working) VCL program it logs it under the "Web session" pane of fiddler and I can read everything. So this fiddler is helping me see that now.

But using the EWB project it never starts a session before throwing the "access is denied" message. I'm not doing much - just loading up that server request and executing.

Inching closer,though!

Jeff
Mon, Jun 4 2012 9:59 AMPermanent Link

Raul

Team Elevate Team Elevate


How are you running the project ?

Possibly looks like cross-domain issue so if you're running it in EWB
make sure built-in web server is turned off.


Raul


On 6/4/2012 4:55 AM, Jeff Newlin wrote:
> But using the EWB project it never starts a session before throwing the "access is denied" message. I'm not doing much - just loading up that server request and executing.
>
> Inching closer,though!
>
> Jeff
>
Mon, Jun 4 2012 8:58 PMPermanent Link

Jeff Newlin

Lightspeed

Ok thanks for pointing me in the right direction Raul. The problem seems to be that I was running the project from a mapped network drive. When I copied the whole thing over to a local hard drive it start working. Seems like I read something along these lines in the forums - but it's easy enough to keep it on local drive while I work on it.

Thanks again!
Jeff




Raul wrote:


How are you running the project ?

Possibly looks like cross-domain issue so if you're running it in EWB
make sure built-in web server is turned off.


Raul


On 6/4/2012 4:55 AM, Jeff Newlin wrote:
> But using the EWB project it never starts a session before throwing the "access is denied" message. I'm not doing much - just loading up that server request and executing.
>
> Inching closer,though!
>
> Jeff
>
Tue, Jun 5 2012 9:01 AMPermanent Link

Raul

Team Elevate Team Elevate

Jeff,

Great you got it resolved and thanks for posting the resolution as it
might be useful for others.

This one sounds like a untrusted source issue. Since Javascript runs
inside the browser all of the sandboxing and other security features
come into play.

Raul


On 6/4/2012 8:58 PM, Jeff Newlin wrote:
> Ok thanks for pointing me in the right direction Raul. The problem seems to be that I was running the project from a mapped network drive. When I copied the whole thing over to a local hard drive it start working. Seems like I read something along these lines in the forums - but it's easy enough to keep it on local drive while I work on it.
>
> Thanks again!
> Jeff
Image