java - 仅在使用 UNITY3d 构建的 Android 应用程序中实例化 SoapService 时出现 ArgumentException

标签 java c# unity-game-engine soap wsdl

我制作了一个 Unity 游戏,它调用一个服务来获取游戏数据。 当从 Unity 播放器启动游戏时,它工作正常,但是当我构建 apk 并在 Android 设备上运行它时,我在 logCat 中收到错误:

Error Unity: ArgumentException: Item has already been added. Key in dictionary: ':Users:::' Key being added: ':Users:::'

Error Unity: at System.Collections.Hashtable.Insert (System.Object key, System.Object nvalue, System.Boolean add) [0x001d4] in <599589bf4ce248909b8a14cbe4a2034e>:0

Error Unity: at System.Collections.Hashtable.Add (System.Object key, System.Object value) [0x00000] in <599589bf4ce248909b8a14cbe4a2034e>:0

Error Unity: at System.Collections.DictionaryBase.System.Collections.IDictionary.Add (System.Object key, System.Object value) [0x00016] in <599589bf4ce248909b8a14cbe4a2034e>:0

Error Unity: at System.Xml.Serialization.TempAssembly+TempMethodDictionary.Add (System.String key, System.Xml.Serialization.TempAssembly+TempMethod value) [0x00006] in :0

Error Unity: at System.Xml.Serialization.TempAssembly.InitAssemblyMethods (System.Xml.Serialization.XmlMapping[] xmlMappings) [0x00063] in :0

Error Unity: at System.Xml.Serialization.TempAssembly..ctor (System.Xml.Serialization.XmlMapping[] xmlMappings, Sy

为了调用服务,我创建了一个 WebClient 文件夹,其中包含通过命令生成的 System.Web.Services.dll 和 wsdl-c# 文件。

这是ServiceSoap.cs文件内容:

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name = "ServizioNumbersSoap", Namespace = "http://tempuri.org/")]
public partial class ServizioNumbers : System.Web.Services.Protocols.SoapHttpClientProtocol
{

    private System.Threading.SendOrPostCallback getSolutionsbyGridOperationCompleted;

    private System.Threading.SendOrPostCallback getGridOperationCompleted;

    private System.Threading.SendOrPostCallback getUserOperationCompleted;

    private System.Threading.SendOrPostCallback setUsersOperationCompleted;

    private System.Threading.SendOrPostCallback updUserScore1OperationCompleted;

    /// <remarks/>
    public ServizioNumbers()
    {
        this.Url = "http://numbers.jemaka.it/NumberService.asmx";
    }

    /// <remarks/>
    public event getSolutionsbyGridCompletedEventHandler getSolutionsbyGridCompleted;

    /// <remarks/>
    public event getGridCompletedEventHandler getGridCompleted;

    /// <remarks/>
    public event getUserCompletedEventHandler getUserCompleted;

    /// <remarks/>
    public event setUsersCompletedEventHandler setUsersCompleted;

    /// <remarks/>
    public event updUserScore1CompletedEventHandler updUserScore1Completed;

    /// <remarks/>
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/getSolutionsbyGrid", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public Solutions[] getSolutionsbyGrid(int idGrid)
    {
        object[] results = this.Invoke("getSolutionsbyGrid", new object[] {
                    idGrid});
        return ((Solutions[])(results[0]));
    }

    /// <remarks/>
    public void getSolutionsbyGridAsync(int idGrid)
    {
        this.getSolutionsbyGridAsync(idGrid, null);
    }

    /// <remarks/>
    public void getSolutionsbyGridAsync(int idGrid, object userState)
    {
        if ((this.getSolutionsbyGridOperationCompleted == null))
        {
            this.getSolutionsbyGridOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetSolutionsbyGridOperationCompleted);
        }
        this.InvokeAsync("getSolutionsbyGrid", new object[] {
                    idGrid}, this.getSolutionsbyGridOperationCompleted, userState);
    }

    private void OngetSolutionsbyGridOperationCompleted(object arg)
    {
        if ((this.getSolutionsbyGridCompleted != null))
        {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getSolutionsbyGridCompleted(this, new getSolutionsbyGridCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/getGrid", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public Grids getGrid()
    {
        object[] results = this.Invoke("getGrid", new object[0]);
        return ((Grids)(results[0]));
    }

    /// <remarks/>
    public void getGridAsync()
    {
        this.getGridAsync(null);
    }

    /// <remarks/>
    public void getGridAsync(object userState)
    {
        if ((this.getGridOperationCompleted == null))
        {
            this.getGridOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetGridOperationCompleted);
        }
        this.InvokeAsync("getGrid", new object[0], this.getGridOperationCompleted, userState);
    }

    private void OngetGridOperationCompleted(object arg)
    {
        if ((this.getGridCompleted != null))
        {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getGridCompleted(this, new getGridCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/getUser", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public Users getUser(string uuid)
    {
        object[] results = this.Invoke("getUser", new object[] {
                    uuid});
        return ((Users)(results[0]));
    }

    /// <remarks/>
    public void getUserAsync(string uuid)
    {
        this.getUserAsync(uuid, null);
    }

    /// <remarks/>
    public void getUserAsync(string uuid, object userState)
    {
        if ((this.getUserOperationCompleted == null))
        {
            this.getUserOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetUserOperationCompleted);
        }
        this.InvokeAsync("getUser", new object[] {
                    uuid}, this.getUserOperationCompleted, userState);
    }

    private void OngetUserOperationCompleted(object arg)
    {
        if ((this.getUserCompleted != null))
        {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getUserCompleted(this, new getUserCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/setUsers", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public string setUsers(Users u)
    {
        object[] results = this.Invoke("setUsers", new object[] {
                    u});
        return ((string)(results[0]));
    }

    /// <remarks/>
    public void setUsersAsync(Users u)
    {
        this.setUsersAsync(u, null);
    }

    /// <remarks/>
    public void setUsersAsync(Users u, object userState)
    {
        if ((this.setUsersOperationCompleted == null))
        {
            this.setUsersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnsetUsersOperationCompleted);
        }
        this.InvokeAsync("setUsers", new object[] {
                    u}, this.setUsersOperationCompleted, userState);
    }

    private void OnsetUsersOperationCompleted(object arg)
    {
        if ((this.setUsersCompleted != null))
        {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.setUsersCompleted(this, new setUsersCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/updUserScore1", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public void updUserScore1(int id_user, float score1)
    {
        this.Invoke("updUserScore1", new object[] {
                    id_user,
                    score1});
    }

    /// <remarks/>
    public void updUserScore1Async(int id_user, float score1)
    {
        this.updUserScore1Async(id_user, score1, null);
    }

    /// <remarks/>
    public void updUserScore1Async(int id_user, float score1, object userState)
    {
        if ((this.updUserScore1OperationCompleted == null))
        {
            this.updUserScore1OperationCompleted = new System.Threading.SendOrPostCallback(this.OnupdUserScore1OperationCompleted);
        }
        this.InvokeAsync("updUserScore1", new object[] {
                    id_user,
                    score1}, this.updUserScore1OperationCompleted, userState);
    }

    private void OnupdUserScore1OperationCompleted(object arg)
    {
        if ((this.updUserScore1Completed != null))
        {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.updUserScore1Completed(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }

    /// <remarks/>
    public new void CancelAsync(object userState)
    {
        base.CancelAsync(userState);
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://tempuri.org/")]
public partial class Solutions
{

    private int id_solutionField;

    private int id_gridField;

    private float numberField;

    private string sequenceField;

    private float difficultyField;

    private string noteField;

    /// <remarks/>
    public int Id_solution
    {
        get
        {
            return this.id_solutionField;
        }
        set
        {
            this.id_solutionField = value;
        }
    }

    /// <remarks/>
    public int Id_grid
    {
        get
        {
            return this.id_gridField;
        }
        set
        {
            this.id_gridField = value;
        }
    }

    /// <remarks/>
    public float Number
    {
        get
        {
            return this.numberField;
        }
        set
        {
            this.numberField = value;
        }
    }

    /// <remarks/>
    public string Sequence
    {
        get
        {
            return this.sequenceField;
        }
        set
        {
            this.sequenceField = value;
        }
    }

    /// <remarks/>
    public float Difficulty
    {
        get
        {
            return this.difficultyField;
        }
        set
        {
            this.difficultyField = value;
        }
    }

    /// <remarks/>
    public string Note
    {
        get
        {
            return this.noteField;
        }
        set
        {
            this.noteField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://tempuri.org/")]
public partial class Users
{

    private int id_userField;

    private string nicknameField;

    private string imeiField;

    private string uuidField;

    private System.DateTime data_setupField;

    private string emailField;

    private string service_idField;

    private string noteField;

    private float score1Field;

    private float score2Field;

    private float bonus1Field;

    private float bonus2Field;

    /// <remarks/>
    public int Id_user
    {
        get
        {
            return this.id_userField;
        }
        set
        {
            this.id_userField = value;
        }
    }

    /// <remarks/>
    public string Nickname
    {
        get
        {
            return this.nicknameField;
        }
        set
        {
            this.nicknameField = value;
        }
    }

    /// <remarks/>
    public string Imei
    {
        get
        {
            return this.imeiField;
        }
        set
        {
            this.imeiField = value;
        }
    }

    /// <remarks/>
    public string Uuid
    {
        get
        {
            return this.uuidField;
        }
        set
        {
            this.uuidField = value;
        }
    }

    /// <remarks/>
    public System.DateTime Data_setup
    {
        get
        {
            return this.data_setupField;
        }
        set
        {
            this.data_setupField = value;
        }
    }

    /// <remarks/>
    public string Email
    {
        get
        {
            return this.emailField;
        }
        set
        {
            this.emailField = value;
        }
    }

    /// <remarks/>
    public string Service_id
    {
        get
        {
            return this.service_idField;
        }
        set
        {
            this.service_idField = value;
        }
    }

    /// <remarks/>
    public string Note
    {
        get
        {
            return this.noteField;
        }
        set
        {
            this.noteField = value;
        }
    }

    /// <remarks/>
    public float Score1
    {
        get
        {
            return this.score1Field;
        }
        set
        {
            this.score1Field = value;
        }
    }

    /// <remarks/>
    public float Score2
    {
        get
        {
            return this.score2Field;
        }
        set
        {
            this.score2Field = value;
        }
    }

    /// <remarks/>
    public float Bonus1
    {
        get
        {
            return this.bonus1Field;
        }
        set
        {
            this.bonus1Field = value;
        }
    }

    /// <remarks/>
    public float Bonus2
    {
        get
        {
            return this.bonus2Field;
        }
        set
        {
            this.bonus2Field = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://tempuri.org/")]
public partial class Grids
{

    private int id_gridField;

    private string itemField;

    private System.DateTime data_creationField;

    private float difficultyField;

    private Solutions solutionsField;

    /// <remarks/>
    public int Id_grid
    {
        get
        {
            return this.id_gridField;
        }
        set
        {
            this.id_gridField = value;
        }
    }

    /// <remarks/>
    public string Item
    {
        get
        {
            return this.itemField;
        }
        set
        {
            this.itemField = value;
        }
    }

    /// <remarks/>
    public System.DateTime Data_creation
    {
        get
        {
            return this.data_creationField;
        }
        set
        {
            this.data_creationField = value;
        }
    }

    /// <remarks/>
    public float Difficulty
    {
        get
        {
            return this.difficultyField;
        }
        set
        {
            this.difficultyField = value;
        }
    }

    /// <remarks/>
    public Solutions Solutions
    {
        get
        {
            return this.solutionsField;
        }
        set
        {
            this.solutionsField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
public delegate void getSolutionsbyGridCompletedEventHandler(object sender, getSolutionsbyGridCompletedEventArgs e);

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class getSolutionsbyGridCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
{

    private object[] results;

    internal getSolutionsbyGridCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
            base(exception, cancelled, userState)
    {
        this.results = results;
    }

    /// <remarks/>
    public Solutions[] Result
    {
        get
        {
            this.RaiseExceptionIfNecessary();
            return ((Solutions[])(this.results[0]));
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
public delegate void getGridCompletedEventHandler(object sender, getGridCompletedEventArgs e);

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class getGridCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
{

    private object[] results;

    internal getGridCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
            base(exception, cancelled, userState)
    {
        this.results = results;
    }

    /// <remarks/>
    public Grids Result
    {
        get
        {
            this.RaiseExceptionIfNecessary();
            return ((Grids)(this.results[0]));
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
public delegate void getUserCompletedEventHandler(object sender, getUserCompletedEventArgs e);

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class getUserCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
{

    private object[] results;

    internal getUserCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
            base(exception, cancelled, userState)
    {
        this.results = results;
    }

    /// <remarks/>
    public Users Result
    {
        get
        {
            this.RaiseExceptionIfNecessary();
            return ((Users)(this.results[0]));
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
public delegate void setUsersCompletedEventHandler(object sender, setUsersCompletedEventArgs e);

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class setUsersCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
{

    private object[] results;

    internal setUsersCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
            base(exception, cancelled, userState)
    {
        this.results = results;
    }

    /// <remarks/>
    public string Result
    {
        get
        {
            this.RaiseExceptionIfNecessary();
            return ((string)(this.results[0]));
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
public delegate void updUserScore1CompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);

为了在 GameManger.cs 中调用服务,我这样做:

     void Start()
    {
       srv = new ServizioNumbers(); <--- Here handle's error
    }

我做错了什么?!

我发布了我在游戏中定义的 SOAP 客户端代码,以便任何人都可以重现该问题。

最佳答案

您无法真正在移动平台上使用 WSDL、SOAP 或 XML 序列化。尝试在 Android 中使用 Mono 运行时选项和最新 (4.5) .net 运行时。您将无法使用il2cpp

关于java - 仅在使用 UNITY3d 构建的 Android 应用程序中实例化 SoapService 时出现 ArgumentException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58564370/

相关文章:

java - Java 方法参数可以是声明大小的集合吗?

unity-game-engine - 正确地为 float3 着色器上的 "Semantic"标记?

C# RichTextBox Find() 错误?

android - 应用内计费 v3 unity onActivityResult

java - 带有 Unity 的 Google 云平台

java - Android应用程序,检查带有INTEGER的EditText是否为空

java - 在布局顶部添加描边

远程计算机上的 Java 登录用户名

c# 检查给定的 Sharepoint 路径是否是根 sharepoint 路径?

c# - 元组旨在解决什么需求?