Search Unity

Creating C# stub from WSDL?

Discussion in 'Editor & General Support' started by hsparra, Aug 18, 2005.

  1. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    Do I need to install Mono in order to create the C# stubs from the WSDL file and to then compile the stub? Or should I use Boo or Javascript?
     
  2. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    Eh...?

    You just add the cs files to the project and unity will compile them for you... Actually it's not possible to add precompiled assemblies to a project.
     
  3. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    I guess my question really revolved around the wsdl command that generates the C# stub source. Is there a way to run that command, or a similar type command, or do I need to code out my own stub? Of course, since I am not familiar with calling SOAP services, especially from C#, my question may make no sense. If so, just let me know :)
     
  4. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    I guess you can install a mono runtime and the wsdl.exe and run it by typing something like:
    Code (csharp):
    1.  
    2.   mono wsdl.exe [url]http://....WSDL_URL[/url]....
    3.  
    And the copy the c# files into the unity project folder.

    .... I haven't tested that though.... and have never done anything with SOAP or Web services.... (always thought SOAP is an overkill....)

    If you have control of the server side, I'd suggest creating a simple CGI script on the server and then use the Unity built-in WWW class to fetch it, passing parameters in the URL query sting, and then parse the output from the script manually. (Which would be in a easily parsed plain text format defined by you...)
     
  5. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    I tend to agree SOAP is overkill. Unfortunately, I am not the owner of the service :( I will check if they have an XML-RPC version.
     
  6. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    Which Mono Classes, or namespace, is Unity using for its WWW implementations? It does not seem that Unity has the System.Web.Services namespace. I am not sure if Mono lacks this also.
     
  7. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    The WWW class in unity is implemented in C and C++ using libcurl, so we have not used the .Net framework for that.
     
  8. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    8) Can I access libcurl from Unity also?
     
  9. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    Only through the interface we have provided, I'm afraid.
     
  10. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104
    I've been following this thread for a while and I have to admit it's not entirely clear to me what problem you are trying to solve.

    I don't know of course, but I suspect that if you lay out the pieces a solution can be found.

    d.
     
  11. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    Oh sorry about that :oops:

    I want to access a web service (SOAP) and then integrate that external data into the game while it is running. There may be a version of the service, or a similar service, that is RPC. Specifically, I want to get stock quotes. I know, strange, but I have an idea I want to try out.
     
  12. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104
    Didn't want to sound harsh, just had a feeling we were "walking 'round the porridge" like we say in Denmark :)

    Any suggestions anyone? I'm too busy on the Unity 1.1 announcement right now to try out any ideas... but if no one replys I'll get back to it later. Just ping me if I forget.

    d.
     
  13. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    Don't worry, you didn't sound harsh to me.

    As an update, I downloaded Mono and installed. Received the same error when trying to compile the .cs file generated from the wsdl command. The fix for this was to add -r:System.Web.Services at the end of the command. So, for the GoogleSearch the command was: mcs /target:library GoogleSearchService.cs -r:System.Web.Services. Of course, that does not help me since I cannot add the dll :cry: I do have a compiled dll though. I believe it is something about System.Web.Services being private in Mono.

    So, is there a way to add the reference so Unity will be able to compile the .cs file?
     
  14. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    As a temp work around, I am hoping to another server for the SOAP call. However, how do I not block the game while waiting for the response?

    I tried the yield instruction like it is on the WWW script page, but I get a script error on the "yield download;" line. The error is, "Update cannot be a coroutine". Commenting out the line allows the script to compile, but the game blocks.

    Do I need to spin off my own thread and keep a reference to that thread in my script?
     
  15. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    You can't use yield inside an update function.
    Make a new function and call it using StartCoroutine.
     
  16. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    Doh! That did the trick. Thank you :D