RE: Asychronous web service call using WSE 3.0
- From: GCR <GCR@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 8 Dec 2005 07:29:03 -0800
Here's a quick sample, which works fine:
namespace Consumer
{
class Program
{
static void Main(string[] args)
{
Adapter ad = new Adapter();
Console.ReadLine();
}
}
class Adapter
{
MySvc.MyServiceWse proxy = null;
public Adapter()
{
this.proxy = new Consumer.MySvc.MyServiceWse();
this.proxy.MyWSOpCompleted +=new
Consumer.MySvc.MyWSOpCompletedEventHandler(proxy_MyWSOpCompleted);
for (int i = 0; i <= 5; i++)
{
this.proxy.MyWSOpAsync(i.ToString(),(object)(Guid.NewGuid()));
Console.WriteLine("Instance " + i.ToString() + " called!");
}
Console.WriteLine("Finished all calls!");
}
private void proxy_MyWSOpCompleted(Object sender,
MyWSOpCompletedEventArgs e)
{
Console.WriteLine("An instance retrurned: " + e.Result);
}
}
}
The proxy class looks like this:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services",
"2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="MyServiceSoap",
Namespace="http://tempuri.org/")]
public partial class MyServiceWse :
Microsoft.Web.Services3.WebServicesClientProtocol {
private System.Threading.SendOrPostCallback MyWSOpOperationCompleted;
private bool useDefaultCredentialsSetExplicitly;
/// <remarks/>
public MyServiceWse() {
this.Url =
global::Consumer.Properties.Settings.Default.Consumer_MySvc_MyService;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}
public new string Url {
get {
return base.Url;
}
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly ==
false))
&& (this.IsLocalFileSystemWebService(value) ==
false))) {
base.UseDefaultCredentials = false;
}
base.Url = value;
}
}
public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
}
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
}
}
/// <remarks/>
public event MyWSOpCompletedEventHandler MyWSOpCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/MyWSOp",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string MyWSOp(string info) {
object[] results = this.Invoke("MyWSOp", new object[] {
info});
return ((string)(results[0]));
}
/// <remarks/>
public void MyWSOpAsync(string info) {
this.MyWSOpAsync(info, null);
}
/// <remarks/>
public void MyWSOpAsync(string info, object userState) {
if ((this.MyWSOpOperationCompleted == null)) {
this.MyWSOpOperationCompleted = new
System.Threading.SendOrPostCallback(this.OnMyWSOpOperationCompleted);
}
this.InvokeAsync("MyWSOp", new object[] {
info}, this.MyWSOpOperationCompleted, userState);
}
private void OnMyWSOpOperationCompleted(object arg) {
if ((this.MyWSOpCompleted != null)) {
System.Web.Services.Protocols.InvokeCompletedEventArgs
invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.MyWSOpCompleted(this, new
MyWSOpCompletedEventArgs(invokeArgs.Results, invokeArgs.Error,
invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
public new void CancelAsync(object userState) {
base.CancelAsync(userState);
}
private bool IsLocalFileSystemWebService(string url) {
if (((url == null)
|| (url == string.Empty))) {
return false;
}
System.Uri wsUri = new System.Uri(url);
if (((wsUri.Port >= 1024)
&& (string.Compare(wsUri.Host, "localHost",
System.StringComparison.OrdinalIgnoreCase) == 0))) {
return true;
}
return false;
}
}
.
- Follow-Ups:
- RE: Asychronous web service call using WSE 3.0
- From: ershad
- RE: Asychronous web service call using WSE 3.0
- From: ershad
- RE: Asychronous web service call using WSE 3.0
- From: ershad
- RE: Asychronous web service call using WSE 3.0
- References:
- Asychronous web service call using WSE 3.0
- From: ershad
- RE: Asychronous web service call using WSE 3.0
- From: GCR
- RE: Asychronous web service call using WSE 3.0
- From: ershad
- Asychronous web service call using WSE 3.0
- Prev by Date: RE: Asychronous web service call using WSE 3.0
- Next by Date: RE: Asychronous web service call using WSE 3.0
- Previous by thread: RE: Asychronous web service call using WSE 3.0
- Next by thread: RE: Asychronous web service call using WSE 3.0
- Index(es):