This article talks about SOAP 1.2 and a brief description of how to make SOAP 1.2 Web Services in .NET Framework 2.0.

Introduction

SOAP version 1.2 (SOAP) is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. It uses XML technologies to define an extensible messaging framework providing a message construct that can be exchanged over a variety of underlying protocols. The framework has been designed to be independent of any particular programming model and other implementation specific semantics.

The technological foundation that makes up Web services includes SOAP, the Web Service Description Language (WSDL), Universal Description, Discovery, and Integration (UDDI), and XML. Specifically, SOAP provides a heterogeneous mechanism to allow the invocation and communication between Web services.

Some of the shortcomings of the SOAP 1.1 has been clarified, updated and corrected in SOAP 1.2. SOAP 1.2 contains a number of issues such as those on interoperability and ambiguities that resulted in differences of interpretation.

SOAP 1.1 is based on XML 1.0 and can only use HTTP POST headers to transmit SOAP messages. As a result, it isn't really suitable for wide-scale applications.

SOAP 1.2

SOAP 1.2 provides a tighter, more robust set of specifications based on an abstract model for binding protocols and XML serialization schemes. SOAP 1.2 also has been tested by a wide variety of participants, including IBM, Microsoft, Sun Microsystems, BEA systems, and the Apache Software Foundation. It has undergone many reviews and drafts and has seen a tremendous amount of public feedback. The W3C tested the interoperability of the specifications by successfully implementing seven projects.

SOAP 1.2 is now extensively documented in three parts: a Primer, Complete Messaging Framework, and Model and Optional Add-ins. SOAP 1.2 is now defined as an XML infoset, not XML syntax.

SOAP Version Information

Comparison between SOAP 1.1 and SOAP 1.2

  1. SOAP 1.1 is based on XML 1.0; SOAP 1.2 is based on XML Infoset.
  2. In SOAP 1.2 it is left to the specification of a binding to an underlying protocol to specify the XML serialization used in the underlying protocol data units.
  3. The HTTP binding specified in SOAP 1.2 uses XML 1.0 as the serialization format of the SOAP message infoset.
  4. SOAP 1.1 allows additional elements to follow the SOAP Body element, SOAP 1.2 disallows these.
  5. SOAP 1.1 has the actor attribute. In SOAP 1.2 this attribute is renamed to role. The semantics of the attribute are unchanged.
  6. SOAP 1.2 adds two new predefined roles to the existing "Next" role in SOAP 1.1:
    • "None" for header blocks that should never be directly processed.
    • "Ultimate Receiver" for header blocks that should only be processed by nodes acting as the ultimate receiver of a message.
  7. HTTP GET support

Carrying of a SOAP 1.1 message was discussed using only HTTP POST. SOAP 1.2 adds support for the use of HTTP GET in the SOAP HTTP binding. The semantics of HTTP GET are respected such that the action performed by SOAP endpoint responding to a request transmitted via HTTP GET should be both safe and idempotent.

Rules for dealing with SOAP 1.1 and SOAP 1.2 version interactions are as follows:

  1. When a SOAP 1.2 message reaches a SOAP 1.1 node it will generate a SOAP fault containing a version mismatch.
  2. When a SOAP 1.2 node receives a SOAP 1.1 message it can do one of the two things as stated below:
    • The node may process the SOAP 1.1 message.
    • It generates a Fault containing a Version Mismatch.

SOAP 1.2 in .NET Framework 2.0

The new ASMX runtime in .NET 2.0 supports SOAP 1.2. At this moment SOAP 1.1 is most widely being used in the industry. In the .NET Framework both SOAP 1.1 and SOAP 1.2 are supported. This means that the Web Services created in .NET Framework 2.0 will be configured to support both SOAP 1.1 and SOAP 1.2 messages. This indirectly means that the WSDLs thus created for the Web Service will have two types of bindings, i.e., SOAP 1.1 and SOAP 1.2.

Hide   Copy Code
<wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
<wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">

Whether both these bindings have to be added to the web service can be configured by enabling or disabling them from the web.config file.

<configuration>
<system.web>
<webServices>
<protocols>
<remove name="HttpSoap12"/>
</protocols>
</webServices>
</system.web>
</configuration>

Replace "HttpSoap12" with "HttpSoap" to remove the SOAP 1.1 binding.

The enumeration value must be one of the following: UnknownHttpSoapHttpGetHttpPostDocumentationHttpPostLocalhostHttpSoap12AnyHttpSoap.

Creating a SOAP 1.2 Web Service in Microsoft Visual Studio 2005 Beta 2

  1. Click on “File—New—Web Site”.
  2. Select folder “E:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebServices\WebSite1”.

    Here we can use IIS (then we need to specify HTTP in the Location dropdown list). Visual Studio 2005 supports internal server, thus IIS is not required. We can use the test server. It is known as the file system.

  3. Select language as C#.
  4. Open the Service.cs file.
  5. Namespaces that are included are:
    Hide   Copy Code
    using System;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
  6. Create a WebMethod:
    Hide   Copy Code
    [WebMethod]
    public long CheckBalance(int iAccountNo)
    {
    //Business Logic......
    //return balance
    return iBalance;
    }
  7. Now edit the web.config file to allow or disallow various protocols used for invocation as described above.
  8. Go to the WebService properties and turn off NTLM authentication.
  9. Build the solution

SOAP request and response

SOAP 1.1

Hide   Shrink    Copy Code
Request:
POST /WS1/Service.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/CheckBalance" <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CheckBalance xmlns="http://tempuri.org/">
<iAccountNo>int</iAccountNo>
</CheckBalance>
</soap:Body>
</soap:Envelope> Response:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CheckBalanceResponse xmlns="http://tempuri.org/">
<CheckBalanceResult>long</CheckBalanceResult>
</CheckBalanceResponse>
</soap:Body>
</soap:Envelope>

SOAP 1.2

Hide   Shrink    Copy Code
Request:
POST /WS1/Service.asmx HTTP/1.1
Host: localhost
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length <?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<CheckBalance xmlns="http://tempuri.org/">
<iAccountNo>int</iAccountNo>
</CheckBalance>
</soap12:Body>
</soap12:Envelope> Response:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length <?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<CheckBalanceResponse xmlns="http://tempuri.org/">
<CheckBalanceResult>long</CheckBalanceResult>
</CheckBalanceResponse>
</soap12:Body>
</soap12:Envelope>

WSDL (binding elements)

Hide   Copy Code
<wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="CheckBalance">
<soap:operation
soapAction="http://tempuri.org/CheckBalance" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="CheckBalance">
<soap12:operation
soapAction="http://tempuri.org/CheckBalance" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

Client Side

On the client side, WSDL.EXE generates SOAP 1.1 proxy code by default. There is a /protocol command line option to WSDL.EXE that allows you to specify which version to use. /protocol:SOAP generates a SOAP 1.1 client and /protocol:SOAP12 generates a SOAP 1.2 client:

Hide   Copy Code
C:\>wsdl /o: proxy.cs /protocol:SOAP http://localhost:2881/WS1/Service.asmx
Microsoft (R) Web Services Description Language Utility
[Microsoft(R) .NET Framework, Version 2.0.40607.85]
Copyright (C) Microsoft Corporation. All rights reserved. Writing file 'proxy.cs'. C:\>wsdl /o: proxy12.cs /protocol:SOAP12 http://localhost:2881/WS1/Service.asmx
Microsoft (R) Web Services Description Language Utility
[Microsoft(R) .NET Framework, Version 2.0.40607.85]
Copyright (C) Microsoft Corporation. All rights reserved. Writing file ‘proxy12.cs'. C:\>

The System.Web.Services.Protocols.SoapHttpClientProtocol class that is used as the base class of the generated client proxies has a new property SoapVersion. This is set to SoapProtocolVersion.Soap12 to indicate that SOAP 1.2 should be used. The correct binding name is also chosen from the WSDL.

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

C#,SOAP1.1与1.2的发布与禁用(SOAP 1.2 in .NET Framework 2.0)的更多相关文章

  1. 发布Framework 4.0到iis时,出现HTTP 错误 403.14 - Forbidden

    新发布MVC到服务器的时候,经常碰到403.14错误,绝大部分的时候都是因为Framework 4.0需要重新注册下,在运行里输入:C:\Windows\Microsoft.NET\Framework ...

  2. Spring Framework 4.0.0发布,首次支持Java 8

    Spring项目组今天发布了Spring 框架4.0.0版本.Spring是一个开源的轻量级Java SE和Java EE开发应用框架,其目的是用于简化企业级应用程序开发. Spring框架第一个版本 ...

  3. IIS首次发布VS2012创建的web应用程序时注册.net4.0

    最近用VS2012创建的web应用程序,.net环境设置成了4.0,在用IIS发布的时候发现需要注册下.net4.0才能配置应用程序. 首先确保配置的电脑上已经安装了.net4,找到.net4所在文件 ...

  4. 发布并开源自己的一款 基于.Net 4.0 及 netstandard2.0 的 ORM 框架

    这款ORM框架的原版在经历过大概十几个项目的磨合,最近整理了一下,原名字为:ZhCun.Framework ,该框架辗转跟了我去过几家公司,大概从2012年出现第一个版本,当时就为简化数据库操作,从优 ...

  5. WCF技术的不同应用场景及其实现分析

    这一篇文章,是总结一下WCF技术,以及基于这个技术发展出来的几个典型应用场景,并且我将尝试对这些不同的WCF实现的原理进行一些比较分析. 关于WCF这个技术的基本概念,如果你不是很清楚,可以参考一下有 ...

  6. 你的项目应当使用Spring Boot吗?(译文)

    注:这是一篇译文,参考链接:https://www.e4developer.com/2018/09/24/should-you-use-spring-boot-in-your-project/ Spr ...

  7. axis2设置soap1.1或soap1.2协议

    现在Axis.Axis2都是同时支持SOAP1.1和SOAP1.2的.即在服务器端发布一个WebService服务之后,客户端既可以通过SOAP1.1版本来访问服务器的服务,也可以通过SOAP1.2版 ...

  8. ASP.NET MVC 应用,站点发布到本地IIS

    材料准备 visual studio 2013 , iis 7 具体步骤 1.以管理员身份启动visual studio 2.新建项目 web app 或者站点 3.编译项目 4.右击项目选择publ ...

  9. IIS7.0发布Web服务器0002

    asp.net发布到IIS中出现错误:处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler” 分类: BS学 ...

随机推荐

  1. 【转载】maven入门1

    学习maven的使用,看到一篇很实用的入门教程(菜鸟级入门) 2007-08-28 14:01:04 标签:maven 职场 休闲 一.前言         早就知道maven 在java 项目的管理 ...

  2. 1.1 C++布尔类型(bool)

    注意: c++ 中 cout << true << endl;  输出为 1: 布尔类型(bool)是C++新增的一种基本数据类型.在标准的C语言中并未定义bool类型,如果需 ...

  3. 实现checkbox的多选

    checkbox多选 技术一般水平有限,有什么错的地方,望大家指正. 全选,多选都是为了使用的方便,一般情况下全选就够用了,但是用户要求实现一个多选的功能也没有办法老老实实的做吧. 多选的实现也较为简 ...

  4. Windows8连接网络后自动弹出Bing解决方法

    Windows8 网络连接速度很快( ADSL ),但是连接之后总是会打开 Bing,这是很烦人的一件事,因为你连接网络可能并不想打开浏览器,甚至,你讨厌 Bing. 我也一直被这个问题困扰了很久,用 ...

  5. STL标准库-仿函数与仿函数适配器

    技术在于交流.沟通,本文为博主原创文章转载请注明出处并保持作品的完整性 概要: 1.仿函数 2.bind2nd() 3.not1() 4.bind() 仿函数的实现:声明一个类,重载它的operato ...

  6. Bypass WAF

    一.绕过命令执行: 很多WAF会限制参数字符不能为可以执行的命令,诸如ls.nc等,如果直接使用这些字符会直接被WAF拦截,但是可以通过这种的方式绕过这一限制 1.? 符号:这个符号表示条件测试,比如 ...

  7. JDK中Integer类的进制转换实现

    JDK中关于Integer类的进制转换方法很精巧,具体实现如下: final static char[] digits = { '0' , '1' , '2' , '3' , '4' , '5' , ...

  8. Android 源码阅读之SMS,MMS

    主界面: com.android.mms.ui.ConversationList.java  [extends ListActivity] 点击新建信息:onListItemClick -〉 posi ...

  9. CODEFORCES 340 XOR and Favorite Number 莫队模板题

    原来我直接学的是假的莫队 原题: Bob has a favorite number k and ai of length n. Now he asks you to answer m queries ...

  10. dockercompose up build fail (node no such file or directory packages.json )

    docker构建项目遇到如下问题: npm ERR! Darwin 15.0.0 npm ERR! argv "/usr/local/lib/node_modules/iojs-bin/no ...