0

Is it possible to get the result of SOAP web service and then pass it with AJAX to other SOAP web service using jQuery?

acdcjunior
  • 132,397
  • 37
  • 331
  • 304
Keen-EGS
  • 23
  • 1
  • 7

1 Answers1

0

Technically, yes.

From a HTML page, trough Ajax, it is possible to call a SOAP web service because, from a technical standpoint:

  • A SOAP call is just a HTTP POST request (thus can be done, you'd have to just build the SOAP envelope yourself); and
  • A SOAP response is just a XML file (thus can be parsed - though not as easy as Json).

But there's a caveat to that:

They all (the two services and the page) would have to be at the same domain or the two webservices must implement support CORS requests.

Check this answer for a detailed explanation of why CORS is a trouble. This question (the question where that answer is, actually), shows an example of a HTML that can call a SOAP web service.

Enabling CORS in ASP.NET web services:

You can just add the header through ASP.NET by adding the following line to your source pages:

Response.AppendHeader("Access-Control-Allow-Origin", "*");

More details in: Using CORS to access ASP.NET services across domains

Community
  • 1
  • 1
acdcjunior
  • 132,397
  • 37
  • 331
  • 304
  • Actually, Im trying to get the result of my webservice. but its looks like I will have trouble with CORS because I have same issue with thread that you've given to me. Is there any other way to get the xml result of web service by jquery?? – Keen-EGS Apr 19 '13 at 01:14
  • By the way. Base on the thread that Im referring, my web service is in the other pc, and Im doing my Mobile apps in my Pc. sO it will have a Cors request not a post? – Keen-EGS Apr 19 '13 at 02:26
  • You see, if it is on another host (that is, cross-domain) you'll have to enable CORS in order for you to call it from a browser. The method (GET, POST, whatever) do not matter: everything, if on another host, is CORS. – acdcjunior Apr 19 '13 at 03:06
  • but if you can change the web service code, you can make it accept CORS. In what language are they? – acdcjunior Apr 19 '13 at 03:07
  • So the answer is Change the web service code to allow the cross origin ? is there any other option? to bypass ..Im creating a ipad apps(html,js,css) with soap web service. Thank you for your response. Im so new about this – Keen-EGS Apr 19 '13 at 08:35
  • thanks for the thread Its been 2 days that I want to get the response of the web service but it looks like I have to deal with the cross – Keen-EGS Apr 19 '13 at 08:37
  • Yes, if you want to call it from a **browser** and from a page that is not at the same domain of the service, you will have to enable cross origin on the service. Jsonp would be an option, but as you want SOAP web services, they cant help, as they cant do POST. – acdcjunior Apr 20 '13 at 01:45
  • How to allow cross origin in web service?. – Keen-EGS Apr 22 '13 at 02:03
  • It can be done. What language is it in? You'll have to change the service's (in the server) code. (Not that I won't help you, but this is now another question, maybe you'd have better luck opening a new one.) – acdcjunior Apr 22 '13 at 02:13
  • Asp.net sir. We are using Asp.net .ASMX – Keen-EGS Apr 22 '13 at 02:22
  • There you go, I added some very good pointers to get you on your way. As I said, if you have trouble getting it done, I suggest you create another question. – acdcjunior Apr 22 '13 at 02:29
  • Last thing sir. If I get enable the cross origin in my service even my apps and service does not in the same domain,. It will give response? currently we are trying to enable the cross origin in the service – Keen-EGS Apr 22 '13 at 09:14
  • Yes, they will give response. That's the purpose of enabling cross-origin. (You see, you are needing to enable cross-origin because you are trying to call you service from a browser (using JQuery) which page is at another domain. If you have apps ,that aren't in a browser, you don't need CORS. The limitation is in browsers only.) – acdcjunior Apr 22 '13 at 12:14
  • I already get the response using responsetext. Thanks Men. ur such a good help may next problem is putting in a listview in jquery mobile. Is it a new post? or possible here? – Keen-EGS Apr 23 '13 at 02:43
  • Definitely a new post. Make sure you tag it good (will enhance your chances): javascript, jquery, jquery-mobile – acdcjunior Apr 23 '13 at 02:45