05的WEB SERVICE 调用后生成总是提示 并不包含RequestSoapContext定义
03里也是一样 但是03里引用后可以更改Reference.cs里的默认继承类为Microsoft.Web.Services2.WebServicesClientProtocol 就可以了,05里不知道在哪改
我安装了WSE2.0 就是不生成以Wse结尾的扩展类 不知道为什么,那位熟悉的指教了啊
03里也是一样 但是03里引用后可以更改Reference.cs里的默认继承类为Microsoft.Web.Services2.WebServicesClientProtocol 就可以了,05里不知道在哪改
我安装了WSE2.0 就是不生成以Wse结尾的扩展类 不知道为什么,那位熟悉的指教了啊
一般情况下直接引用是可以的
如果要用wse要另外引用其他的类库
要求用web service实现跨服务器传文件,vs03里可以 我改成05的就有那问题了
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Web;
using System.Web.Services;
using Microsoft.Web.Services2;
using System.Web.Services.Protocols;
using Microsoft.Web.Services2.Dime;
/// <summary>
/// SHIL_Service 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SHIL_Service : System.Web.Services.WebService//Microsoft.Web.Services2.WebServicesClientProtocol
{ public SHIL_Service () { //如果使用设计的组件,请取消注释以下行
//InitializeComponent();
} /// <summary>
/// This method initializes a buffered upload. It creates a temporary file on the
/// server's temp directory and a session object that references the temp file. It returns
/// a string value representing the InstanceId of the buffered upload. This id should be
/// passed to the proceding calls to AppendChunk(), Save(), and Close() methods.
/// </summary>
[WebMethod(EnableSession = true)]
public string Initialize(string Filename, bool Overwrite)
{
return new Instance(Filename, Overwrite).Initialize().Id;
} /// <summary>
/// This method appends a dime attachment to an upload in progress.
/// </summary>
/// <param name="InstanceId">The string returned by Initialize() method.</param>
/// <param name="offset">The offset at which to start writing.</param>
/// <param name="length">The size of the buffer.</param>
[WebMethod(EnableSession = true)]
public void AppendChunk(string InstanceId, long offset, int bufferSize)
{
Instance i = Instance.GetInstanceById(InstanceId);
if (i != null)
{
if (RequestSoapContext.Current == null || RequestSoapContext.Current.Attachments.Count == 0)
throw new SoapFormatException("No SOAP attachments included in message");
Stream dimeStream = RequestSoapContext.Current.Attachments[0].Stream;
byte[] buffer = new byte[dimeStream.Length];
dimeStream.Read(buffer, 0, buffer.Length);
dimeStream.Close();
i.AppendChunk(buffer, offset, bufferSize);
}
else
Instance.CustomSoapException("Instance Not Found", InstanceId);
} /// <summary>
/// This method removes the upload instance from session state .
/// </summary>
/// <param name="InstanceId">The string returned by Initialize() method.</param>
[WebMethod(EnableSession = true)]
public void RemoveInstance(string InstanceId)
{
Instance i = Instance.GetInstanceById(InstanceId);
if (i != null)
i.RemoveFromSession();
// else: nothing to remove anyway, so don't report any errors.
}
}
用wsdl.exe 和dicover.exe重生成代理类 那这两个EXE要安装吗
也不知道怎么搞
需要修改配置文件 <httpRuntime maxRequestLength="100000" executionTimeout="300" /> 来支持大文件 另外,如果可能,你可以考虑使用WSE,这样可以开启MTOM,这样对于这种数据,会直接传输字节而不是编码Base64的编码。
这么做后,你需要重新编译项目,包括客户端,他们都给引用这个WSE,客户端引用后,重新生成代理类,会多出一个WSE代理, 如,有个服务名叫Service,那么引用WSE后,就有有2个一个Service,一个ServiceWSE。只有后者支持MTOM。另外,对于服务器端配置,是否使用的MTOM好像都是指进入,而输出始终会使用MTOM,因此不用WSE的代理类会报错.上面是网上看到的一段资料 可我的就是没有代理类啊
就可以修改 编译通过了