soap is not working after convert to WebGL

Hi everybody, I have used soap to make a game. I wrote the web service with .asmx extension and then I converted to .cs extension. and then I created the .dll library. I have used the library in my unity game without any problem!!!
but after build WebGL, I have had error after click on my object!!

This is my error:

MissingMethodException: No constructor found for System.Web.Services.Protocols.SoapTypeStubInfo::.ctor(System.Web.Services.Protocols.LogicalTypeInfo)

This is my web service:

<%@ WebService language = "C#" class = "FirstService" %>
using System;
using System.Web.Services;
using System.Xml.Serialization;
[WebService(Namespace = "http://localhost/UnityWebServices/")]
public class FirstService : WebService
{
            [WebMethod]
            public int Add(int a, int b)
            {
                   return a + b;
            }
            [WebMethod]
            public String SayHello()
            {
                   return "Hello World";
            }
}

I used this command to make the .cs file by mono:

wsdl FirstService.wsdl

and then I used this command to make .dll file:

dmcs /target:library FirstService.cs r:System.Web.Services

and then I have used in my unity, this library. It’s working without any problem!!!

but after convert to WebGL is not working and I have had error in my browser’s console!!

I changed API compatibility level to .net 2.0 too! But still has a error!!

please help me! I’m trying to fix this, but I’m new in unity…

I’m using visual studio 2015…

The class that this error is referring is the following: (I made with this command → wsdl FirstService.wsdl ← by mono compiler)

/// CodeRemarks
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="FirstServiceSoap", Namespace="http://localhost/UnityWebServices/")]
public partial class FirstService : System.Web.Services.Protocols.SoapHttpClientProtocol {
    private System.Threading.SendOrPostCallback AddOperationCompleted;
    private System.Threading.SendOrPostCallback SayHelloOperationCompleted;
    /// CodeRemarks
    public FirstService() {
        this.Url = "http://localhost/unitywebservices/firstservice.asmx";
    }
    /// CodeRemarks
    public event AddCompletedEventHandler AddCompleted;
    /// CodeRemarks
    public event SayHelloCompletedEventHandler SayHelloCompleted;
    /// CodeRemarks
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/UnityWebServices/Add", RequestNamespace="http://localhost/UnityWebServices/", ResponseNamespace="http://localhost/UnityWebServices/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public int Add(int a, int b) {
        object[] results = this.Invoke("Add", new object[] {
                    a,
                    b});
        return ((int)(results[0]));
    }
    /// CodeRemarks
    public void AddAsync(int a, int b) {
        this.AddAsync(a, b, null);
    }
    /// CodeRemarks
    public void AddAsync(int a, int b, object userState) {
        if ((this.AddOperationCompleted == null)) {
            this.AddOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddOperationCompleted);
        }
        this.InvokeAsync("Add", new object[] {
                    a,
                    b}, this.AddOperationCompleted, userState);
    }
    private void OnAddOperationCompleted(object arg) {
        if ((this.AddCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.AddCompleted(this, new AddCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }
    /// CodeRemarks
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/UnityWebServices/SayHello", RequestNamespace="http://localhost/UnityWebServices/", ResponseNamespace="http://localhost/UnityWebServices/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public string SayHello() {
        object[] results = this.Invoke("SayHello", new object[0]);
        return ((string)(results[0]));
    }
    /// CodeRemarks
    public void SayHelloAsync() {
        this.SayHelloAsync(null);
    }
    /// CodeRemarks
    public void SayHelloAsync(object userState) {
        if ((this.SayHelloOperationCompleted == null)) {
            this.SayHelloOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSayHelloOperationCompleted);
        }
        this.InvokeAsync("SayHello", new object[0], this.SayHelloOperationCompleted, userState);
    }
    private void OnSayHelloOperationCompleted(object arg) {
        if ((this.SayHelloCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.SayHelloCompleted(this, new SayHelloCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }
    /// CodeRemarks
    public new void CancelAsync(object userState) {
        base.CancelAsync(userState);
    }
}
/// CodeRemarks
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
public delegate void AddCompletedEventHandler(object sender, AddCompletedEventArgs e);
/// CodeRemarks
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class AddCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
    private object[] results;
    internal AddCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
            base(exception, cancelled, userState) {
        this.results = results;
    }
    /// CodeRemarks
    public int Result {
        get {
            this.RaiseExceptionIfNecessary();
            return ((int)(this.results[0]));
        }
    }
}
/// CodeRemarks
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
public delegate void SayHelloCompletedEventHandler(object sender, SayHelloCompletedEventArgs e);
/// CodeRemarks
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class SayHelloCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
    private object[] results;
    internal SayHelloCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
            base(exception, cancelled, userState) {
        this.results = results;
    }
    /// CodeRemarks
    public string Result {
        get {
            this.RaiseExceptionIfNecessary();
            return ((string)(this.results[0]));
        }
    }
}

Note:
I found the same error in this forum!! but the different is, it was build for iOS, for me is build for WebGL!!!

Two possible causes - one; threading. All the async methods will break in WebGL as threads are not supported; and the wsdl utility will generate them.

Second; the system.web namespace is generally fairly unreliable in Unity. I know it has gotten better in the last few years, but generally speaking I’ve found it less than ideal. It’s probably not supported.

Unfortunately; in all our projects - we end up writing our own client using JSON/XML serialization and the WWW class, bit of a pain - but it seems to be unavoidable.

I solved it!! I use www class and wwwform class for request to server…

Thanks for help AFrisby!

Hi
Please can you share your solved code and what all did you changed to www as I am also facing same problem.

I’m going to guess he rewrote all the client-side to use WWW, I don’t believe there’s an easy fix here.

Unity have added .NET WebRequest at some point, which was the big reason it wasn’t working on any player; but I’m fairly certain that does not work in WebGL (again, due to threading.); if you don’t need it solved this year, there’s a chance we may see shared array buffers & threads in WebGL at some point, but it wont be soon.

In the meantime, you might just be stuck writing the wrapper by hand. You can probably re-use the class declarations that wsdl.exe gives you; since System.Xml can be made to work in WebGL; but the actual post/get methods will need to be custom.