Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
5
Question by paranoid_droid42 · May 01, 2011 at 08:15 PM · standalonewebservicesoap

.exe (Standalone) builds & executes on development PC, but no where else (consumes a .net SOAP web service)

Hi, I'm working to an insane deadline (two days from posting this message!) and posting to this forum for inspiration. It's my first post to these forums so apologies if its directed to the wrong place.

I've built a PC standalone self executable in Unity3 that consumes a .net SOAP webservice. Everything builds fine in the Unity editor and the standalone executable file runs fine on Windows 7 (SP1). The application communicates correctly with the webservice (this web service just takes a string input and returns a random string in response).

The problem is when I try the .exe on another PC. The application crashes when trying to communicate with the .net service. I've tried enabling 'script debugging' and looked at the output trace. The standalone .exe gets as far as communicating then crashes - with no helpful error messages - it just stops logging. If I move the .exe back to the PC that it was developed on, all is fine!?!

I've looked over the forums and checked I've performed the following:

  • The application is NOT being used as a webplayer (.unity3D) - so the web-player sandbox isn't the cause.

  • I've built the wsdl stub class using the Visual Studio command line prompt: wsdl -out:VPDentistv01.cs /protocol:SOAP12 http://www.myserver.com/mywebservice.asmx (I've also used /protocol:SOAP)

  • I've tried communicating with the stub/web service by wraping it into another .net class, that is compiled as a dll (.net 2.0). The dll is placed in the Plugin folder and is present in the Plugin folder of the build.

  • I'm building with the full .net library, not the subset.

  • The test PC I have is also running Win7 SP1 operating system with .net 3.5 framework. I've disabled firewall and anti-virus (yes I'm that desperate!) to check its not blocking communication with the web-service.

I'm out of ideas. I am new to Unity (5 days experience so far) so I've likely missed somethig basic. What I can't understand is why the .exe works on the PC I develop with but not on another PC running the same environment.

I'm aware that its best to post my code as an example, but to be honest I don't think the code is faulty - as its builds and executes as a self executable ok on my dev pc. It seems its a build setting or security / sandbox setting I'm missing.

PS: Not sure if this is significant, but I develop on a MacBook Pro using boot camp. I have Unity installed on the Windows 7 partition of the MacBook where the .exe works fine. However on the Mac partition, a the .app fails (on the same machine).

Any help, or ideas - much appreciated!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Joshua · May 02, 2011 at 12:57 AM 0
Share

Upvote for good question. Can't help you though, I'm sorry.

1 Reply

· Add your reply
  • Sort: 
avatar image
6
Best Answer Wiki

Answer by paranoid_droid42 · May 03, 2011 at 01:02 PM

Thanks for all those who viewed this question. I didn't find a solution but I did find a work-around. I thought I'd post it here in case anyone else had the same problem.

As my web-service was only receiving and returning a string, I was able to configure the .net web service to accept GET requests in the web.config file to cover all methods in the service:

<webServices>
    <protocols>
        <add name="HttpGet"/>
    </protocols>
</webServices>

Alternatively, you can use the following attribute if you wish to limit GET requests to one particular method:

[ScriptMethod(UseHttpGet = true)]
public string HelloWorld()
{
    return "Hello World";
}

Instead of use wsdl to generate a stub, I used the WWW class that sent the url as a string. The string was concatenated to format the GET request for a webservice. The method I used in a Unity c# class is below:

public IEnumerator getMyWebService(string _inputText)    
{    
       string url = "http://www.myserver.com/mywebservice.asmx/myMethod?inputText=" + WWW.EscapeURL(_inputText); 
       WWW www = new WWW(url); 
       yield return www;
       Debug.Log(www.text); //Do something with the response as the www object.    
}

Finally the line of code below was inserted into an Awake(), Start(), Update() or onGUI() method, to invoke the web service as-and-when required:

StartCoroutine(getMyWebService(inputText));

I would have liked to get a solution that used SOAP so I could efficiently handle the retured object from the web service. Hoever the deadline I had meant I had to find a workaround quickly!

This workaround had the added advantage of allowing the Unity project to be compiled as a Web Application (.unity3d) - which is prevented in Unity3 if you use a wsdl stub class / SOAP approach. So some benefits I guess :-)

(If you publish your .unity3d file on the same server as your web-service, then there is no need for a cross domain xml file at the root of the server)

If there is anyone out there ever in the same situation as me, I hope this is of use!


EDIT : Additional Info by Meltdown

To add to Luke's excellent answer, many people may be wondering how to get rid of the XML that is returned with the WWW.text response from the server.

The following method accomplishes this... Courtesy of this post from Snipplr.com

 string StripXML(string source)
     {
         source = source.Replace("\r\n", "");
         char[] buffer = new char[source.Length];
         int bufferIndex = 0;
         bool inside = false;
 
         for (int i = 0; i < source.Length; i++)
         {
             char let = source[i];
             if (let == '<')
             {
                 inside = true;
                 continue;
             }
             if (let == '>')
             {
                 inside = false;
                 continue;
             }
             if (!inside)
             {
                 buffer[bufferIndex] = let;
                 bufferIndex++;
             }
         }
         return new string(buffer, 0, bufferIndex);
     }


Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Meltdown · May 03, 2011 at 01:21 PM 0
Share

Upvote for co$$anonymous$$g back and provding a possible solution :)

avatar image pauljazon · Apr 19, 2012 at 03:20 PM 0
Share

Hmmm, so I guess this means REST (the way you did it above) is best for Unity, not SOAP. I just did a REST service on my project as well. Works like magic.

avatar image Meltdown · Oct 30, 2012 at 05:44 PM 0
Share

Added a convenient method to strip out X$$anonymous$$L from the response :)

avatar image paprocjo · Nov 01, 2012 at 05:07 PM 0
Share

Hopefully I can use this to solve my issues as well since it seem they might be similar.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Web Service not running problem 0 Answers

Can a Unity Stand-Alone EXE run as a service? 1 Answer

Works in the editor, but not when I publish it.. what's wrong..? 0 Answers

Regarding PlayerPrefs vrs. (WebPlayer && Standalone) Builds 1 Answer

the standalone and web build don't run the same as Unity Editos runtime 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges