3
這裏保留到以後的呼叫會話一個ASP.Net Web服務是如何在我的系統設置:如何從SOAP客戶端
- 使用ASP.Net Web服務
- 的Web服務的Web服務有EnableSession一個Web方法=真正的
- 它指的是Web服務使用「服務引用」(注意:不是「Web引用」)客戶
- 客戶端的app.config中有allowCookies =真
在客戶端,我有以下的代碼到一個文件上傳到服務
bool res = service.InitiateUpload();
if (res) {
do {
read = stream.Read(buffer, 0, BLOCK_SIZE);
if (read == BLOCK_SIZE)
res = res && service.AppendUpload(buffer);
else if (read > 0)
// other call to AppendUpload, after buffer manipulation
在服務器端,我來檢查,如果從調用InitiateUpload會話ID是一樣的AppendUpload代碼。
[WebMethod(EnableSession=true)]
public bool InitiateUpload() {
lock (theLock) {
if (IsImportGoingOn)
return false;
theImportDataState = new ImportDataState(Session.SessionID);
}
return true;
}
[WebMethod(EnableSession=true)]
public bool AppendUpload(byte[] data) {
lock (theLock) {
if (!IsImportGoingOn)
return false;
if (theImportDataState.session != Session.SessionID)
return false;
theImportDataState.buffer.AddRange(data);
return true;
}
}
由於會話ID不匹配,對AppendUpload的調用返回false。這是爲什麼? 就我所見,我擁有Web方法的正確屬性,客戶端具有正確的配置,並且使用了同一個代理實例。我錯過了什麼嗎?
+1 this it it it。 – eglasius 2010-09-14 22:07:00