Developer forum

Forum » Development » WebService access

WebService access


Reply
Hi!

How do you do to connect to an external web service from within Dynamicweb?

I have standard aspx page that's gonna be scheduled to run and connect to the web service connected to the ERP system on another server.

Is it just to connect to the service in a normal way as any other aspx page?

But I get "page could not be found" when I'm connecting to the service.

Is this a problem in DW or the external web service?

Best regards,
Per Ljung
REAB Data AB

Replies

 
Reply
Hi Per,

Where is the Web Service located? Inside your custom (modules) Dynamicweb project? If so, the URL may be processed by Dynamicweb's SEO URLs or security features. A common way to handle this is to implement Application_OnPreRequestHandlerExecute in Global.asax, look at the URL and if it matches the service URL, then skip calling GlobalAsax.Application_OnPreRequestHandlerExecute(sender, e);

E.g. something like this should work:

public void Application_OnPreRequestHandlerExecute(object sender, EventArgs e)
{
  if (HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath.ToLower() !=  "~/path/to/your/service.asmx")
  {
    GlobalAsax.Application_OnPreRequestHandlerExecute(sender, e);
  }
}

Hope this helps,

Imar
 
Reply
Oh, crap. just saw you're accessing an external service....Sorry ;-(

In that case, can you post the code you use to connect to your service? There shouldn't be a difference from calling services as you normally would.

And where are you calling this service?

Imar

 
Reply
Hi!

The webservice is an external webservice and located on another server on another domain, it's not placed on the dw server.

By the way when you are connecting to an external erp system, should the webservice be placed on the external server or on the dw server?

Should Dynamic web connect to the external web service or should the external service connect to Dynamicweb.

ERP system -> Webservice on dw, products orders

or

DW -> ERP system webservice

Best regards,
Per
 
Reply
The webservice is called from the Page_Load event handler.

The aspx page is placed in the root of the dw application, when I placed it in the CustomModules folder I was directed to login page.


// Per
 
Reply
>> By the way when you are connecting to an external erp system, should the webservice be placed on the external server or on the dw server?

That depends on your requirements.

Your ERP system may already have web services that expose product data or that accept orders. In that case, you consume the external web service from within a Dynamicweb module or ASPX page or whatever.

If you want to expose data to other systems you need to create a web service inside your project. It all comes down to who initiates the first call. if that's Dynamicweb (for example to submit a completed order) your code should communicate with an external service.

With regard to the page being redirected: the same answer applies as in my initial post: Dynamicweb probably tries to SEO-interpret the (physical) URL. Just exclude your URL in Global.asax.

Hope this helps,

Imar
 
Reply
Hi, it works now!

Thanks for help!

// Per

 

You must be logged in to post in the forum