Problem web service / standalone

Hello,

First of all, sorry if my English is not good, I’m French.

I’m working with Unity 3.3.0 to do a serious game.
I use web services in SOAP.
I used this command line :
wsdl -out:FlorenceService.cs http://adress-of-local-server/webservice-serious?wsdl

Here is the generated code

    //------------------------------------------------------------------------------
// <auto-generated>
//     Ce code a été généré par un outil.
//     Version du runtime :2.0.50727.5448
//
//     Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
//     le code est régénéré.
// </auto-generated>
//------------------------------------------------------------------------------

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

// 
// This source code was auto-generated by Web Services Description Language Utility
//Mono Framework v2.0.50727.5448
//


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="FlorenceBinding", Namespace="http://192.168.175.10/webservice-florence")]
public partial class FlorenceService : System.Web.Services.Protocols.SoapHttpClientProtocol {
    
    private System.Threading.SendOrPostCallback startOperationCompleted;
    
    private System.Threading.SendOrPostCallback finishOperationCompleted;
    
    private System.Threading.SendOrPostCallback setOperationCompleted;
    
    private System.Threading.SendOrPostCallback getOperationCompleted;
    
    /// <remarks/>
    public FlorenceService() {
        this.Url = "http://192.168.175.10/webservice-florence";
    }
    
    /// <remarks/>
    public event startCompletedEventHandler startCompleted;
    
    /// <remarks/>
    public event finishCompletedEventHandler finishCompleted;
    
    /// <remarks/>
    public event setCompletedEventHandler setCompleted;
    
    /// <remarks/>
    public event getCompletedEventHandler getCompleted;
    
    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("http://192.168.175.10/webservice-florence#start", RequestNamespace="http://192.168.175.10/webservice-florence", ResponseNamespace="http://192.168.175.10/webservice-florence")]
    [return: System.Xml.Serialization.SoapElementAttribute("return")]
    public object[] start(string login, string pass, string module_id) {
        object[] results = this.Invoke("start", new object[] {
                    login,
                    pass,
                    module_id});
        return ((object[])(results[0]));
    }
    
    /// <remarks/>
    public void startAsync(string login, string pass, string module_id) {
        this.startAsync(login, pass, module_id, null);
    }
    
    /// <remarks/>
    public void startAsync(string login, string pass, string module_id, object userState) {
        if ((this.startOperationCompleted == null)) {
            this.startOperationCompleted = new System.Threading.SendOrPostCallback(this.OnstartOperationCompleted);
        }
        this.InvokeAsync("start", new object[] {
                    login,
                    pass,
                    module_id}, this.startOperationCompleted, userState);
    }
    
    private void OnstartOperationCompleted(object arg) {
        if ((this.startCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.startCompleted(this, new startCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }
    
    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("http://192.168.175.10/webservice-florence#finish", RequestNamespace="http://192.168.175.10/webservice-florence", ResponseNamespace="http://192.168.175.10/webservice-florence")]
    [return: System.Xml.Serialization.SoapElementAttribute("return")]
    public object[] finish(string session_string, string statut) {
        object[] results = this.Invoke("finish", new object[] {
                    session_string,
                    statut});
        return ((object[])(results[0]));
    }
    
    /// <remarks/>
    public void finishAsync(string session_string, string statut) {
        this.finishAsync(session_string, statut, null);
    }
    
    /// <remarks/>
    public void finishAsync(string session_string, string statut, object userState) {
        if ((this.finishOperationCompleted == null)) {
            this.finishOperationCompleted = new System.Threading.SendOrPostCallback(this.OnfinishOperationCompleted);
        }
        this.InvokeAsync("finish", new object[] {
                    session_string,
                    statut}, this.finishOperationCompleted, userState);
    }
    
    private void OnfinishOperationCompleted(object arg) {
        if ((this.finishCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.finishCompleted(this, new finishCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }
    
    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("http://192.168.175.10/webservice-florence#set", RequestNamespace="http://192.168.175.10/webservice-florence", ResponseNamespace="http://192.168.175.10/webservice-florence")]
    [return: System.Xml.Serialization.SoapElementAttribute("return")]
    public object[] set(string label, string value, string session_string) {
        object[] results = this.Invoke("set", new object[] {
                    label,
                    value,
                    session_string});
        return ((object[])(results[0]));
    }
    
    /// <remarks/>
    public void setAsync(string label, string value, string session_string) {
        this.setAsync(label, value, session_string, null);
    }
    
    /// <remarks/>
    public void setAsync(string label, string value, string session_string, object userState) {
        if ((this.setOperationCompleted == null)) {
            this.setOperationCompleted = new System.Threading.SendOrPostCallback(this.OnsetOperationCompleted);
        }
        this.InvokeAsync("set", new object[] {
                    label,
                    value,
                    session_string}, this.setOperationCompleted, userState);
    }
    
    private void OnsetOperationCompleted(object arg) {
        if ((this.setCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.setCompleted(this, new setCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
        }
    }
    
    /// <remarks/>
    [System.Web.Services.Protocols.SoapRpcMethodAttribute("http://192.168.175.10/webservice-florence#get", RequestNamespace="http://192.168.175.10/webservice-florence", ResponseNamespace="http://192.168.175.10/webservice-florence")]
    [return: System.Xml.Serialization.SoapElementAttribute("return")]
    public object[] get(string label, string value, string session_string) {
        object[] results = this.Invoke("get", new object[] {
                    label,
                    value,
                    session_string});
        return ((object[])(results[0]));
    }
    
    /// <remarks/>
    public void getAsync(string label, string value, string session_string) {
        this.getAsync(label, value, session_string, null);
    }
    
    /// <remarks/>
    public void getAsync(string label, string value, string session_string, object userState) {
        if ((this.getOperationCompleted == null)) {
            this.getOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetOperationCompleted);
        }
        this.InvokeAsync("get", new object[] {
                    label,
                    value,
                    session_string}, this.getOperationCompleted, userState);
    }
    
    private void OngetOperationCompleted(object arg) {
        if ((this.getCompleted != null)) {
            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
            this.getCompleted(this, new getCompletedEventArgs(invokeArgs.Results, 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")]
public delegate void startCompletedEventHandler(object sender, startCompletedEventArgs e);

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class startCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
    
    private object[] results;
    
    internal startCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
            base(exception, cancelled, userState) {
        this.results = results;
    }
    
    /// <remarks/>
    public object[] Result {
        get {
            this.RaiseExceptionIfNecessary();
            return ((object[])(this.results[0]));
        }
    }
}

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

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class finishCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
    
    private object[] results;
    
    internal finishCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
            base(exception, cancelled, userState) {
        this.results = results;
    }
    
    /// <remarks/>
    public object[] Result {
        get {
            this.RaiseExceptionIfNecessary();
            return ((object[])(this.results[0]));
        }
    }
}

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

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class setCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
    
    private object[] results;
    
    internal setCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
            base(exception, cancelled, userState) {
        this.results = results;
    }
    
    /// <remarks/>
    public object[] Result {
        get {
            this.RaiseExceptionIfNecessary();
            return ((object[])(this.results[0]));
        }
    }
}

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

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "0.0.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class getCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
    
    private object[] results;
    
    internal getCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
            base(exception, cancelled, userState) {
        this.results = results;
    }
    
    /// <remarks/>
    public object[] Result {
        get {
            this.RaiseExceptionIfNecessary();
            return ((object[])(this.results[0]));
        }
    }
}

It works fine in Unity but when I do an executable, my script can’t access to the web service. I have this exception in the output log :

    TypeLoadException: A type load exception has occurred.
  at System.Web.Services.Protocols.SoapExtension.GetTypeExtensions (System.Type serviceType) [0x00000] in <filename unknown>:0 

  at System.Web.Services.Protocols.SoapTypeStubInfo..ctor (System.Web.Services.Protocols.LogicalTypeInfo logicalTypeInfo) [0x00000] in <filename unknown>:0 

  at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (object,object[],System.Exception&)

  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00109] in /Applications/buildAgent/work/e259f8a4bed15472/mcs/class/corlib/System.Reflection/MonoMethod.cs:513 
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00124] in /Applications/buildAgent/work/e259f8a4bed15472/mcs/class/corlib/System.Reflection/MonoMethod.cs:519 

  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Applications/buildAgent/work/e259f8a4bed15472/mcs/class/corlib/System.Reflection/MonoMethod.cs:528 

  at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x001b8] in /Applications/buildAgent/work/e259f8a4bed15472/mcs/class/corlib/System/Activator.cs:338 

  at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in /Applications/buildAgent/work/e259f8a4bed15472/mcs/class/corlib/System/Activator.cs:268 

  at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in /Applications/buildAgent/work/e259f8a4bed15472/mcs/class/corlib/System/Activator.cs:263 

  at System.Web.Services.Protocols.LogicalTypeInfo.CreateTypeStubInfo (System.Type type) [0x00000] in <filename unknown>:0 

  at System.Web.Services.Protocols.LogicalTypeInfo.GetTypeStub (System.String protocolName) [0x00000] in <filename unknown>:0 

  at System.Web.Services.Protocols.TypeStubManager.GetTypeStub (System.Type t, System.String protocolName) [0x00000] in <filename unknown>:0 

  at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor () [0x00000] in <filename unknown>:0 

  at FlorenceService..ctor () [0x00000] in <filename unknown>:0 

  at (wrapper remoting-invoke-with-check) FlorenceService:.ctor ()

  at ClientObjet.Awake () [0x00020] in C:\Users\David\Documents	runk\Unity - Simulateur\prod V3\Assets\WebClient\ClientObjet.cs:26 

Could everyone help me please ?

Thanks in advance

Hi dunachu,

I had roughly the same error messages, but thanks to a great article by Stig Olavsen, I seem to have gotten rid of the errors… his article is here:

http://randomrnd.com/2011/08/21/webservices-in-unity/

I had included the correct two DLL needed for SOAP in the Assets/Plugins/ folder, but in my case I hadn’t changed the “API compatibility layer” Settings to “.NET 2.0” (Edit > Project Settings > Player > Other Settings). Sadly, in my case I was actually hoping to get SOAP working via the Web Player (rather than a standalone), which I can see now has actually been disabled. I’m still pretty new to Unity, but since Web Services are disabled in Web Player builds (for “security reasons”) I’m pretty sure my only option is to use the WWW class… nevertheless I have written a tiny bit of what I learnt, plus a list of Unity-SOAP threads here:

http://www.andrewnoske.com/wiki/index.php?title=Unity_-_SOAP_Interaction

Hope some of these articles help. – Andrew.