0

I have designed a web based calculator. But I want to have this calculator run on a web service(WSDL). I'm using C# and Javascript behind the back of my website. So could you help me where to add the WSDL descriptions in code and where? If required I can put my code here. Best regards.

1 Answer 1

3

You need to make a request to the webservice, you don't need to put WSDL into javascript.

Calling a webservice is a request like any other request, you can use AJAX with JQuery for example:

$.ajax({
  type: "POST",
  contentType: "application/json; charset=utf-8",
  url: "WebService.asmx/WebMethodName",
  data: "{}",
  dataType: "json"
});

Example from: http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/

Sign up to request clarification or add additional context in comments.

7 Comments

Thank you for your reply. Sorry I'm quite new to this web service operations. So will my code look like this after I add the request? $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "WebService.asmx/WebMethodName", data: "{}", dataType: "json" }); //rest of the javascript code goes here...
If you want to use web service with javascript (in this case jquery). Check the link I put there. If you want to use the webservice from the code of you website, you should add a web reference to that. This will create the proxy to the WS automatically.
Well I used "Add Service Reference" by right-clicking the solution on Visual Studio 2010 and I successfully added the web service address to the project. Now my website still runs perfectly so could I say that my application uses the web service and does the calculation on it?
Your application has the proxy to connect to the webservice. You still need to call method from webservices to use the webservice. I mean, you need to create the code in the webservice to do the maths and then, call it from client-side or server-side (wtv you prefer).
Well I have defined methods in the web service (etc. Add, Multiply...) but I have FUNCTIONS in my javascript code so would that still make it work on the web service or what I should do? Sorry I'm asking too much but I'm completely new to this.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.