mtelligent

View Original

Exam 70-554 - Configuring and Customizing a Web Service Application Configure SOAP messages.

I haven't posted in a while. I really wanted to post a summary on 70-553 before going into 70-554, but its just taking so long. So with that in mind, here is the first installment of notes on Exam 70-554.

 

Section 1

  • Part 1
    Configuring and Customizing a Web Service Application
    • Topic 1

Configuring and Customizing a Web Service Application Configure SOAP messages.

  • Configure the formatting of SOAP messages for a Web service method.
  • Specify the basic information for a Web service application.
  • Specify the bindings of a Web service application by using the WebServiceBindingAttribute attribute.
  • Configure a Web service application by using a Machine.config file.
  • Configure a Web service application by using a Web.config file.

Summary

You can modify the default SOAP formatting for all methods in web service by applying to SoapRpcService or SoapDocumentService attribute to the Web Service class or SoapRpcMethod or SoapDocumentMethod attribute to the Method. The attributes will affect the WSDL for the ASMX.

The SoapRpcService and SoapRpcMethod Attribute allow you to set the encoding style of the SOAP message. There are two encoding styles: Document and RPC. RPC refers to encoding all the parameters of a web service method into an element named after the method.

The SoapDocumentService and SoapDocumentMethod Attribute allow you to set the format for the SOAP requests and responses. The format is determined by two parameters: Use and ParameterStyle. Use can be set the formatting to either encoded or literal. Literal refers to using an xsd schema for each parameter. ParameterStyle can be used to set the formatting to Bare (Parameters are sent in elements following the BODY element), Default (Specifies Wrapped), and Wrapped (Parameters are encapsulated within a single element following the BODY element).

The WebServiceBindingAttribute Class can be used to define the binding of a web service method. Bindings enable you to change the namespace for certain methods, or even specify the bindings in a separate file (another web service or even a hand written wsdl file). Basically you can define your bindings (name, namespace, location) and then use SoapDocumentMethod Attribute to associate the binding with the method. Bindings can also be thought of as an interface, a contract that enables you to bind the contract to the actual asmx implementation.

Here is an example of its usage from msdn2:

// Binding is defined in this XML Web service and uses the default namespace.
[ WebServiceBinding(Name="LocalBinding")] // Binding is defined in this XML Web service, but it is not a part of the default namespace.
[ WebServiceBinding(Name="LocalBindingNonDefaultNamespace",
Namespace="http://www.contoso.com/MyBinding" )] // Binding is defined on a remote server, but this XML Web service implements at least one operation in that binding.
[ WebServiceBinding(Name="RemoteBinding",
Namespace="http://www.contoso.com/MyBinding",
Location= http://www.contoso.com/MySevice.asmx?wsdl)]
public class BindingSample
{

[ SoapDocumentMethod(Binding="LocalBinding")]
[ WebMethod() ]
public string LocalBindingMethod() {
return "Member of binding defined in this XML Web service and member of the default namespace";
}

[ SoapDocumentMethod(Binding="LocalBindingNonDefaultNamespace")]
[ WebMethod() ]
public string LocalBindingNonDefaultNamespaceMethod() {
return "Member of binding defined in this XML Web service, but a part of a different namespace";
}

[ SoapDocumentMethod(Binding="RemoteBinding")]
[ WebMethod() ]
public string RemoteBindingMethod() {
return "Member of a binding defined on another server";
}

[ WebMethod() ]
public string DefaultBindingMethod() {
return "Member of the default binding";
}

}

Web Service Configuration options that can be modified through Web.Config or machine.config include protocols, wsdlHelpGenerator along with other standard asp.Net configurable behaviors.

The Protocols element is beneath the WebServices element and can be configured with multiple options including: HttpSoap (Configured by default, this enables support for SOAP over http), HttpGet (Support for invoking services through Http Get (parameters passed through querystring)), HttpPost (Support for invoking services through Http Get (parameters passed sent in post request header)), HttpPostLocalhost (Only allows post for local requests), Documentation (specifies if web service help page is displayed when asmx is navigated to directly)

The wsdlHelpGenerator node enables you to specify a custom page that users should see when navigating to a web service directly. This enables you to brand or extend the pages capabilities. The default page is specified in the machine.config to point to DefaultWsdlHelpGenerator.aspx.

Other Resources & Links:

How to: Modify the Default SOAP Formatting for an Entire Web Service
http://msdn2.microsoft.com/en-us/library/0d91a695.aspx

Customizing SOAP Formatting (Links to Attributes)
http://msdn2.microsoft.com/en-us/library/dkwy2d72.aspx

WebServiceBindingAttribute Class
http://msdn2.microsoft.com/en-us/library(d=robot)/system.web.services.webservicebindingattribute.aspx

Configuration Options for XML Web Services Created Using ASP.NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconConfigurationOptionsForASPNETWebServices.asp