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!!!