Web Services
%@ WebService directive instead of Page,
[WebService] attribute above the code behind class that defines the namespace.
[WebMethod (enableSessionState, transactionOption, cacheDuration, bufferResponse)]
//Web methods must return a [Serializable] object with a default constructor.
Calling from client script
Add [System.Web.Script.Services.ScriptService] above code behind class definition.
Ensure the ScriptHandlerFactory HTTP handler is registered for asmx files in the web.config.
Add to the ScriptManager on the page:
Services
asp:ServiceReference path="MyWebService.asmx"
//Call in javascript
string result = MyWebService.MyWebMethod();
Security
| Windows Basic Authentication | Popup for authentication, clear text. |
| Windows Basic Authentication over SSL | Entire communication call encrypted (slow) |
| Client Certificates | Obtained from trusted certificate authority, certificate mapped to user. |
| Windows Digest | Similar to basic but sent encrypted, needs to both be on windows though. |
| Forms based authentication | Not supported for web services |
| Windows Integrated | Encrypted and automatic. Needs to be on windows though. |
| Custom SOAP Headers | Can be used for non-windows platforms. |