开发者

Is it possible to create a SOAP API using C# and JavaScript

开发者 https://www.devze.com 2023-01-18 23:00 出处:网络
I am looking to create a SOA开发者_如何学PythonP API using C# which I can then call using JavaScript.I use C# regularly but do not have any experience with creating API\'s.I would like to call the API

I am looking to create a SOA开发者_如何学PythonP API using C# which I can then call using JavaScript. I use C# regularly but do not have any experience with creating API's. I would like to call the API using JavaScript as this will be used to submit form data from multiple websites not maintained by us.

If there is a better solution than SOAP I am open to suggestions.

If anyone can point me to examples or has any examples they can share I would appreciate it.

TIA BrianKE

EDIT: I should have mentioned that I would to deploy a solution that will allow form data from multiple websites, not under our domain, to submit data directly to our database, hence the API. Perhaps there is a different way to handle this other than an API that I am not aware of.


If there is a better solution than SOAP?

If you are going to consume the API from javascript JSON is preferred. You may checkout this example which illustrates how to expose a JSON enabled WCF service for consumption from jquery AJAX.


Yes. You can.

Barring small issues/restrictions with XHR, it's perfectly "fine" to consume SOAP services from JS. The biggest issue is "dealing" with the XML, which can be more cumbersome than JSON (but it isn't bad if you use the correct tools such as XPath extractors). For my projects I use a small wrapper setup for the AJAX/XHR/SOAP call (not WSDL generated) that can take custom encoding/decoding functions.

Google searches shows several promising results/examples including JavaScript SOAP Client.

Note: If you need cross-domain access there are several methods including a proxy or the newer cross-domain XHR support (however, these require client and/or server support) or, depending on client, just really relaxed settings. These cross-domain considerations are generally no different than if using "REST" or other web-service APIs.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号