cancel
Showing results for 
Search instead for 
Did you mean: 

Add a page to call a webservice

SOLVED

Add a page to call a webservice

Hi I am totally new with Magento.

I extended the order/observer and it works well.

 

I want to add a page with a textbox and a button.

The goal is to call a .net wcfservice with the textbox input and return some data (an array of strings) and then to present it on the page as a result.

 

I read about widgets, blocks and other, but what is the best way to care of this?

 

regards

 

Ric Lo

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Add a page to call a webservice

Some ideas (I know there are plenty of code over internet but I'll sugeest some core code).

 

  1. Take a look to the Contact module. There you'll find something simple and similar to your request (a form with to controller's actions).
  2. If your request to your webservice is using SOAP, be sure to be able to handle timeouts (it's tricky with SOAP). If not, if webservice fails, you'll be block on that page.

 

View solution in original post

6 REPLIES 6

Re: Add a page to call a webservice

Hi @RicLo,


It seems there are several things you will need to handle.

1) You've mentioned observers. What are you doing with observers?

2) Also, on which page you'll show that information?

3) How will be the call to the webservice exectued? Which gonna be the trigger?

 

 

Re: Add a page to call a webservice

Hi Damian,

I am software developer, but new to magento and php.

I mentioned the observer as an example to inform about the level of my knowledge.

and to let people know where i've already been in my few days of magento/php. 

So it has nothing to do with my question.

But to answer your question. After an order has created. I send some order data to an external webservice. This .net wcf service executes some extra actions. I just followed some samples on the internet to get this going. It works well.

 

I want to create a page where people can insert a number in a textbox and there's a submit button. After they hit the submit button. Then this number will be send to another external webservice. In return it will receive some data, which should be presented on the same page

(as some labels). Just like below (from another webste) ...

Schermafbeelding 2017-09-27 om 23.01.37.png

In the main menu there will be a menuoption to start this page.

 

Hope it's more clear now. I just want to know what is the best way to start this.

 

Ric Lo

Re: Add a page to call a webservice

Hi @RicLo,

 

So, basically, you'll need a custom page (controller + block + layout + phtml) and then, your form will post the data to your own controller and there you'll call your model who will call your webservice (or maybe a library instead a model).

Is this the main idea, right?

Re: Add a page to call a webservice

yes, you are absolutely right 

 

so, you just pointed me already in a direction 

Re: Add a page to call a webservice

Some ideas (I know there are plenty of code over internet but I'll sugeest some core code).

 

  1. Take a look to the Contact module. There you'll find something simple and similar to your request (a form with to controller's actions).
  2. If your request to your webservice is using SOAP, be sure to be able to handle timeouts (it's tricky with SOAP). If not, if webservice fails, you'll be block on that page.

 

Re: Add a page to call a webservice

Ok, thanks man.

That's a good place to start