Web Service应用举例 及一问题的解决方法

由于系统要求 需要做一webservice将应用服务器的压力分配到其它的机器上,于是写了下面的WebSerivce服务
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using DBCore;

namespace QQWebService
{
 /// <summary>
 /// QQMessage 的摘要说明。
 /// </summary>
 [WebService(Namespace="QQWebService")]
 public class QQMessage : System.Web.Services.WebService
 {
  DBCore.DataBaseVisitor.AbsDBHelper dbhelper = new DBCore.DataBaseVisitor.FactoryDBHelper().CreateDBHelper("DataBaseSql",DBCore.DataBaseVisitor.DataBaseConnectionType.Sql);

  public QQMessage()
  {
   //CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
   InitializeComponent();
  }

  [WebMethod]
  public void SetDBHelperofSQLClient(string  conn)
  {
   this.dbhelper = new DBCore.DataBaseVisitor.JSLSqlHelper();
   dbhelper.SetDBConnection = conn;
  }

  [WebMethod]
  public DataSet GetSender(string userid)
  {
   string sql="select distinct Sender from tOA_Message_Temp_User where   IsRead='0' and receiver='"+userid+"'";
   return dbhelper.ExecuteDataset(sql);
  }
...

   [WebMethod]
  public DataSet CSelectSys(ArrayList al)
  {
   if (al == null) return null;
   string sql = @"
   Select TopicID,Content,Sender,SendTime,IsSend,IsAutoBack,IsRead,Receiver,ReceiverTime,Sender as username
   From tOA_Message_Temp_User
   where Sender='$0$'
            and Receiver='$1$'
   and IsRead='$2$'
    ";
   for(int i = 0; i < al.Count; i++)
   {
    sql = sql.Replace("$"+i.ToString()+"$",al[i] != null ? al[i].ToString() : "");
   }
   return dbhelper.ExecuteDataset(sql.Replace("\t"," "));
  }

   #region 组件设计器生成的代码
  
  //Web 服务设计器所必需的
  private IContainer components = null;
    
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if(disposing && components != null)
   {
    components.Dispose();
   }
   base.Dispose(disposing);  
  }
  
  #endregion

  }
}

在系统当中添加web引用,关键位置做了如下处理
xxx.QQClient {
    using System.Diagnostics;
    using System.Xml.Serialization;
    using System;
    using System.Web.Services.Protocols;
    using System.ComponentModel;
    using System.Web.Services;
   
   
    /// <remarks/>
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="QQMessageSoap", Namespace="QQWebService")]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(object[]))]
    public class QQMessage : System.Web.Services.Protocols.SoapHttpClientProtocol {
       
        /// <remarks/>
        public QQMessage() {
            this.Url = "http://10.60.0.147/QQWebService/QQMessage.asmx";
        }
 
  public QQMessage(string url)
  {
   this.Url = url;
  }     

  public QQMessage(string url, string conn)
  {
   this.Url = url;
   SetDBHelperofSQLClient(conn);
  }
...

在系统引用webservice时做如下类

using System;
using System.Collections;
using System.Data;
using DBCore;
namespace JQHY.jslqq
{
 /// <summary>
 /// JSLQQSource 的摘要说明。
 /// </summary>
 public class JSLQQSource
 {

  static JQHY.QQClient.QQMessage qc = new JQHY.QQClient.QQMessage(System.Configuration.ConfigurationSettings.AppSettings["QQClientSerivce"],System.Web.HttpContext.Current.Application["DataBaseSql"].ToString());

  static object[ ] ToArray( System.Collections.ICollection coll )
  {
   object[ ] result = new object[coll.Count];
   int i = 0;
   foreach( object obj in coll )
   {
    result[ i++ ] = obj;
   }
   return result;
  }
  public JSLQQSource()
  {

  }

  public DataSet GetSender(string userid)
  {
   return qc.GetSender(userid);
  }
  public DataSet CSelectSys(ArrayList al)
  {
   return qc.CSelectSys(ToArray(al));
  }
...

测试发现web service只能访问本地资源,一直找不到问题所在 。
后来将程序部署到别的机器上试发现没有此类问题,寻找很久,终于解决
得如下结论: :-)

复杂的问题往往有着简单的答案
 [Web Service于Win2003下访问SQLServer2000记得一定要打上SQLSever.SP3补丁]

转载于:https://www.cnblogs.com/bigmouthz/archive/2006/04/19/379260.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/264930.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

[转]Java反射机制详解

目录 1反射机制是什么2反射机制能做什么3反射机制的相关API通过一个对象获得完整的包名和类名实例化Class类对象获取一个对象的父类与实现的接口获取某个类中的全部构造函数 - 详见下例通过反射机制实例化一个类的对象获取某个类的全部属性获取某个类的全部方法通过反射机制调用…

AWS IOT Device C SDK 使用(阿里云一机一密、一型一密、公钥、私钥、CA、根证书、签名、验签、哈希、X.509)

AWS IOT Device C SDK 使用 AWS IOT接入及测试 阿里云设备影子&#xff1a;类似MQTT的遗嘱 阿里云设备接入、设备管理方案 阿里云&#xff1a;一机一密、一型一密、CA证书、证书获取、证书烧录 公钥、私钥、数字签名和数字证书的概念及解密(数字证书&#xff1a;CA用自己的私…

centos 5.8 升级php5.1至5.3

为什么80%的码农都做不了架构师&#xff1f;>>> 1.先查看当前php版本 #php -v 2.升级php版本 #rpm --import http://repo.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy #wget -P /etc/yum.repos.d/ http://repo.webtatic.com/yum/webtatic.repo #yum --enablere…

9种没结果的爱(未婚者必读)!!!

时间可以改变一切&#xff01;”这话不假&#xff0c;但是放在爱情里&#xff0c;你就得掂量掂量。如果你现在正在试图改变你们尴尬的局面&#xff0c;以下8种情况供你参考。没有结果的爱&#xff0c;该放手还是尽快吧。      一、你在乎对方比较多     你在谈恋爱&…

redis集群部署及常用的操作命令_01

简单说下自己测试搭建简单的redis集群的大体步骤&#xff1a; 1.首先你的有6个redis&#xff08;官方说最少6个&#xff0c;3master&#xff0c;3slave&#xff09;&#xff0c;可以先在一台机器上搭建&#xff0c;搭建到多台上应该只需要改变启动命令即可&#xff08;可能需要…

ubuntu网络环境搭建

参考&#xff1a;https://www.bilibili.com/video/BV1n541197rk?spm_id_from333.999.0.0 目录开发板网线直连电脑网口&#xff0c;电脑WIFI上网有的公司保密性强&#xff0c;可能要找网络管理员协助 开发板网线直连电脑网口&#xff0c;电脑WIFI上网 开发板一定要上电并连接到…

linux下ORACLE的Sqlplus命令

一、ORACLE的启动和关闭1、在单机环境下要想启动或关闭ORACLE系统必须首先切换到ORACLE用户&#xff0c;如下su – oracle   1.进入到sqlplus启动实例[rootoracle ~]# su – oracle 切换到oracle用户-bash-3.2$ lsnrctl start a、启动ORACLE系统oracle>svrmg…

在statspack显示完整的SQL

用spreport.sql生成statspack文件时,其中的SQL语句只显示了5行,往往显示不完整,有时又需要完整的SQL来进一步分析SQL的性能问题.以前一直不知道怎么办,今天查资料找到了解决办法. 对于8i,直接修改spreport.sql文件中的下面这一句,把5改为20等更大的值 define num_rows_per_hash…

How to use QueryPerformanceCounter? (c++,不使用 .Net)

出处&#xff1a;https://stackoverflow.com/questions/1739259/how-to-use-queryperformancecounter 参考&#xff1a;https://docs.microsoft.com/zh-cn/windows/desktop/WmiSdk/accessing-performance-data-in-c--#example #include <windows.h>double PCFreq 0.0; _…

高级 IO(非阻塞、多路复用、异步、存储映射、文件锁)

目录非阻塞I/O阻塞I/O 与非阻塞I/O 读文件阻塞I/O 的优点与缺点使用非阻塞I/O实现并发读取I/O 多路复用何为I/O多路复用select()函数poll()函数总结非阻塞I/O 关于“阻塞”一词前面已经给大家多次提到&#xff0c;阻塞其实就是进入了休眠状态&#xff0c;交出了CPU 控制权。前…

程序员---我的读书列表

2019独角兽企业重金招聘Python工程师标准>>> 1、JAVA核心技术 2、knuth《The Art of program》四卷&#xff0c;辅导书《基本数学》 转载于:https://my.oschina.net/muyexia/blog/225376

.NET3.0已经Pre-release了

.NET3.0已经Pre-release了。下面的链接可以下载运行库&#xff1a;http://www.microsoft.com/downloads/details.aspx?FamilyId8D09697E-4868-4D8D-A4CF-9B82A2AE542D&displaylangen它的发布日期是: 2006-06-23在该页面下面的Related Resources有SDK下载Windows SDK for .…

IE11下用forms身份验证的问题

<authentication mode"Forms"><forms name"weboa" loginUrl"login.aspx" protection"All" path"/"/></authentication> 在IE10Mozilla Firefox都正常&#xff0c;升级到IE11的电脑都登陆不了了。。。奇怪…

C语言的枚举类型(Enum)

参考&#xff1a;C语言的枚举类型&#xff08;Enum) 地址&#xff1a;https://blog.csdn.net/aliyonghang/article/details/123615803?spm1001.2014.3001.5502 在实际编程中&#xff0c;有些数据的取值往往是有限的&#xff0c;只能是非常少量的整数&#xff0c;并且最好为每个…

【HDOJ】1597 find the nth digit

二分。 1 #include <stdio.h>2 #include <math.h>3 4 int main() {5 int case_n;6 double n, tmp, l, r;7 int m;8 9 scanf("%d", &case_n); 10 11 while (case_n--) { 12 scanf("%lf", &n); 13 …

(水题)洛谷 - P1603 - 斯诺登的密码

https://www.luogu.org/problemnew/show/P1603 有毒&#xff0c;大小写不检测&#xff0c;句号也不管。 #include<bits/stdc.h> using namespace std; #define ll long longint num[10]; int top0;char s[30];int tonum(){int nstrlen(s);if(strcmp(s,"one")0)…

用SHA1或MD5 算法加密数据(示例:对用户身份验证的简单实现)

(一).功能 用哈希算法: SHA1或MD5 实现用户账号和密码验证. 数据库存储实现原理是: 用户账号直接存储在数据库中&#xff0c;密码经过加密后再存储到数据库中. 当用户登录时&#xff0c;密码要经过加密后再与数据库中的实际存储密码比较&#xff0c;确定是否合法用户…

https网络编程——HTTP协议的简介、HTTP报文结构和代理、HTTP加速解析方法(哈希加速、协议状态机)

参考&#xff1a;HTTP协议的简介及其工作原理等 地址&#xff1a;https://qingmu.blog.csdn.net/article/details/108046553?spm1001.2014.3001.5502 目录HTTP协议的简介及其工作原理1、HTTP简介1.1、什么是超文本&#xff08;HyperText&#xff09;?1.2、什么是URL&#xff…

vim常用命令表

命令模式光标移动h或向左方向键光标向左移动一个字符j或向下方向键光标向下移动一个字符k或向上方向键光标向上移动一个字符l或向右方向键光标向右移动一个字符Ctrlf屏幕向前翻一页&#xff08;常用&#xff09;Ctrlb屏幕向后翻一页&#xff08;常用&#xff09;Ctrld屏幕向前翻…

c# 2.0 Factory的实现

用C#的范型建立一个Factory模式的模板: publicstructFactoryConverter<A, B>{ public static implicit operator A(FactoryConverter<A, B> conv) { return Activator.CreateInstance<A>(); } public static implici…