샘플의 간단한 C# 웹 서비스에 문제가 있습니다. 내가 그렇게 같은 클라이언트에서 서비스를 소비비동기 웹 서비스의 EndInvoke가 쓸모없는 값을 반환합니다.
public delegate string LengthyProcedureAsyncStub(int milliseconds);
public class MyState
{
public string text;
public object previousState;
public LengthyProcedureAsyncStub asyncStub;
}
[WebMethod]
public IAsyncResult BeginLengthyProcedure(int milliseconds, AsyncCallback cb, object s)
{
LengthyProcedureAsyncStub stub = new LengthyProcedureAsyncStub(LengthyProcedure);
MyState ms = new MyState();
ms.previousState = s;
ms.asyncStub = stub;
return stub.BeginInvoke(milliseconds, cb, ms);
}
public string LengthyProcedure(int milliseconds)
{
System.Threading.Thread.Sleep(milliseconds);
return "Success";
}
[WebMethod]
public string EndLengthyProcedure(IAsyncResult call)
{
MyState ms = (MyState)call.AsyncState;
string result = ms.asyncStub.EndInvoke(call);
return result;//ms.text;
}
: 이 내 서버 측 코드
private void button1_Click(object sender, EventArgs e)
{
Waiter(5000);
}
private void Waiter(int milliseconds)
{
asyncProcessor.Service1SoapClient sendReference;
sendReference = new asyncProcessor.Service1SoapClient();
sendReference.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
sendReference.BeginLengthyProcedure(milliseconds, ServiceCallBack, null);
}
private void ServiceCallBack(IAsyncResult result)
{
string strResult = result.ToString();
}
문제는 값의로 클라이언트 변수 strResult 대신, "성공"을 가지고 있어야한다는 것입니다 그것은이 있습니다 : "System.ServiceModel.Channels.ServiceChannel + SendAsyncResult". 내가 뭘 잘못하고 간과하니? 시간 :
스택 오버플로에 오신 것을 환영합니다! 태그는 독자적으로 사용됩니다. 개별 태그를 결합한다고해서 추가 의미가 부여되지는 않습니다. 예를 들어,'web'과'service'를 조합한다고해서 웹 서비스에 관해 말하는 것은 아닙니다. – Charles
@Charles 챨스를 설명해 주셔서 감사합니다. 미래를 염두에 두겠습니다. – user1417947