spring.net 整合Webservice小计
来源:互联网 发布:手机淘宝一阳指在哪里 编辑:程序博客网 时间:2024/06/05 10:28
按照刘冬的
Spring.NET学习笔记21——整合Web Service(应用篇) Level 200 ,用VS2012实现
几处修改:
服务器端
1、在Global.asax的Application_Start中实例化Spring.NET容器
WebApplicationContext ctx = ContextRegistry.GetContext() as WebApplicationContext;
此事可以不做
2、Web.config配置
<?xml version="1.0"?><!-- 有关如何配置 ASP.NET 应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=169433 --><configuration> <configSections> <sectionGroup name="spring"> <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/> <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/> <section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/> </sectionGroup> </configSections> <spring> <parsers> <parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/> <parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data"/> </parsers> <context> <resource uri="assembly://Jesus.Repository/Jesus.Repository.Config/Repository.xml"/> </context> </spring> <system.web> <compilation debug="true" targetFramework="4.0"/> <httpRuntime maxRequestLength="2147483647" executionTimeout="600"/> <httpHandlers> <add verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web"/> </httpHandlers> </system.web> <system.webServer> <handlers> <add name="SpringWebServiceSupport" verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web"/> </handlers> </system.webServer> <object id="UsersServer" type="Spring.Web.Services.WebServiceExporter, Spring.Web"> <property name="TargetName" value="wsUsers"/> <property name="Namespace" value="<a target=_blank href="http://Jesus.ZXJ/'/">http://Jesus.ZXJ/"/</a>> </object></configuration>
其中
<httpHandlers> <add verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web"/> </httpHandlers>
在VS2012中可以没有,但在VS2010中必须有
wsUsers对应的是PersonContract 类Spring节点配置
3、必要引用 ---Spring.Web
客户端
1、App.config配置
<?xml version="1.0"?><configuration> <configSections> <sectionGroup name="spring"> <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/> <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/> <section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/> </sectionGroup> </configSections> <spring> <parsers> <parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/> <parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data"/> </parsers> <context> <resource uri="assembly://Jesus.BLL/Jesus.BLL.Config/Webservice.xml"/> </context> </spring> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> <appSettings> <add key="skin" value="Coffee"/> <add key="url" value="localhost:2727"/> </appSettings> </configuration>
2、Webservice.xml配置
<?xml version="1.0" encoding="utf-8" ?><objects xmlns="http://www.springframework.net"> <object id="wsUsers" type="Jesus.SysUtility.Factory.WebServiceProxyFactory,Jesus.SysUtility"> <constructor-arg value="UsersServer"/> <property name="ServiceInterface" value="Jesus.WebserviceInterface.BasicInformation.IUsers, Jesus.WSI"/> </object></objects>
其中<property name="ServiceInterface" value="Jesus.WebserviceInterface.BasicInformation.IUsers, Jesus.WSI"/>对应的是interface IPersonContract
3、Jesus.SysUtility.Factory.WebServiceProxyFactory,Jesus.SysUtility实现代码
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace Jesus.SysUtility.Factory{ using Spring.Core.IO; using System.Net; public class WebServiceProxyFactory : Spring.Web.Services.WebServiceProxyFactory { static string _url;//= "10.73.58.102"; static string URL{ get{ if (_url==null) { _url = Jesus.Utility.AppConfigHelper.GetAppConfig("url"); } return _url; } } public WebServiceProxyFactory(string webserviceName) { this.ServiceUri = new UrlResource(string.Format("http://{0}/{1}.asmx", URL, webserviceName)); CredentialCache credentialCache = new CredentialCache(); this.Credential = new System.Net.NetworkCredential("sfadministrator", "`qwe123"); } }}
4、调用Webservice
public WebserviceInterface.BasicInformation.IUsers userManageSoapClient { get; set; }
0 0
- spring.net 整合Webservice小计
- struts2 和 spring 整合小计
- xfire+spring整合webservice
- CXF WebService整合Spring
- Spring+webservice的整合
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- webservice axis2+spring整合
- CXF WebService整合Spring
- CXF WebService整合Spring
- 一些有意思的面试题
- JavaScript闭包---笔记摘抄
- ssh配置连接
- ADF知识点
- 011
- spring.net 整合Webservice小计
- ORACLE触发器详解
- HDU4941
- 校赛1
- UVA - 10118Free Candies(记忆化搜索)
- vim 基本操作
- java网络编程
- Android程序中“再按一次退出”的实现
- POJ 2446 Chessboard(二分图最大匹配)