大家好! 我的问题有点麻烦! 现在我已经写好了一个web service 并切已经发布成功! 我现在要手写一个对web service的代理类! 就象添加引用的代理类一样 只是我需要动态的改变对web service的URL 着还是其次! 主要是我的web service 里面的方法 返回的是个自己定义的集合类(MyCollection) 在手写web service代理类的时候要怎么写恩!代码如下namespace WebService1
{
/// <summary>
/// Service1 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
MyCollections coll = new MyCollections();
private MyOperateAccess operateAccess = new MyOperateAccess();
/// <summary>
/// 加栽表名! 在使用前必须运行
/// </summary>
/// <param name="str"></param>
[WebMethod]
public void LoadTableName(string str)
{
// operateAccess.MReflectData.GetTableNames(str);
operateAccess.MReflectData.GetTableNames("DataClass.dll");
} [WebMethod]
public MyCollections SelectFullId(string tableName)
{
return coll=operateAccess.SelectFullId(tableName);
}
}代理类
要怎么写恩! 麻烦给个例子看下
{
/// <summary>
/// Service1 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
MyCollections coll = new MyCollections();
private MyOperateAccess operateAccess = new MyOperateAccess();
/// <summary>
/// 加栽表名! 在使用前必须运行
/// </summary>
/// <param name="str"></param>
[WebMethod]
public void LoadTableName(string str)
{
// operateAccess.MReflectData.GetTableNames(str);
operateAccess.MReflectData.GetTableNames("DataClass.dll");
} [WebMethod]
public MyCollections SelectFullId(string tableName)
{
return coll=operateAccess.SelectFullId(tableName);
}
}代理类
要怎么写恩! 麻烦给个例子看下
有没有人写过类似引用代理类 那种写法的! [System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name = "ServiceSoap", Namespace = "http://tempuri.org/")]
public class MyServiceRef : System.Web.Services.Protocols.SoapHttpClientProtocol
{ public MyServiceRef()
{
this.Url = "http://tempuri.org/";
}
[这里是不是要声明MyCollections 要怎么写恩]
public MyCollections SelectFullId(string tableName)
{
}想这样开头的
打开.net自己带的Visual Studio .NET 2003 命令提示
输入wsdl /language:VB /n:mynamespace /out:myProxyClass.cs http://hostServer/WebserviceRoot/WebServiceName.asmx?WSDL默认为C#语言/language:VB 为输出语言/n:mynamespace namespace/out:myProxyClass.cs 输出文件名
我手写了一个但是老是有异常 说HTTP头不对!
谁能说下! 给个例子! 现在就是要给手写的! 有没有 人知道啊
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name = "Service1", Namespace = "http://tempuri.org/")]
public class MyServiceRef : System.Web.Services.Protocols.SoapHttpClientProtocol
{
[System.Diagnostics.DebuggerStepThroughAttribute()]
public MyServiceRef()
{
this.Url = "http://localhost/rrr/Service1.asmx";
}
//[System.ServiceModel.OperationContractAttribute(Action = "http://localhost:3647/LoadTableName", ReplyAction = "*")]
//[System.ServiceModel.XmlSerializerFormatAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/LoadTableName", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public void LoadTableName(string str)
{ this.Invoke("LoadTableName", new object[] { str });
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SelectFullId", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[XmlInclude(typeof(MyCollections))]
public MyCollections SelectFullId(string tableName)
{ object[] results = this.Invoke("SelectFullId", new object[] { tableName });
return ((MyCollections)(results[0])); }
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SelectInfos", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[XmlInclude(typeof(MyCollections))]
public MyCollections SelectInfo(string tableName, string id)
{ object[] results = this.Invoke("SelectInfo", new object[] { tableName, id });
return ((MyCollections)(results[0])); }
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SelectInfo", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[XmlInclude(typeof(MyCollections))]
public MyCollections SelectInfos(string tableName, string[] id)
{
object[] results = this.Invoke("SelectInfos", new object[] { tableName, id });
return ((MyCollections)(results[0])); }
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SelectFullInfo ", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[XmlInclude(typeof(MyCollections))]
public MyCollections SelectFullInfo(string tableName)
{ object[] results = this.Invoke("SelectFullInfo ", new object[] { tableName });
return ((MyCollections)(results[0])); }