- Home /
Accessing A 3rd party webservice from Unity C#
Please take a look at the directions I was given by this 3rd party partner. I have no control what soever over their website. I work for an architecture firm.
I just need to access this from the unity C# code.
right now I'm doing basically this:
using UnityEngine;
using System.Collections;
using System.Net;
using System.IO;
public class WebServices : MonoBehaviour
{
string access = "http://zimas.lacity.org/zmaWS/ZIMASDataService.svc/GetZIMASAddress?HseNum=200&StrNm=sp";
// Use this for initialization
void Start()
{
StartCoroutine(go());
}
IEnumerator go()
{
WWW wsa = new WWW(access);
yield return wsa;
yield return new WaitForSeconds(2.0f);
print("text... " + wsa.text);
}
void Update() { }
}
Also, I should mention that it's returning a bunch of HT$$anonymous$$L code - not something I can use the information is not there.
Or doesn't seem to be.
text... <!DOCTYPE html PUBLIC "-//W3C//DTD XHT$$anonymous$$L 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>404 - File or directory not found.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet $$anonymous$$S", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>404 - File or directory not found.</h2>
<h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
</fieldset></div>
</div>
</body>
</html>
UnityEngine.$$anonymous$$onoBehaviour:print(Object)
<go>c__Iterator9:$$anonymous$$oveNext() (at Assets/WebServices.cs:26)
That's a 404, which suggests you might have got the URI wrong. Have you verified your access
string by copying it into a browser?
I get the 404 page when I do that. So it looks to me like your code is working.
Yep the html code that is produced by the print() is the same as the HT$$anonymous$$L code of the web page produced by the browser when I do that.
I will have to contact someone who works for the people who gave me the directions.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Web Build Loading Slow 1 Answer
Browser-side WebPlayer application caching. 2 Answers
Display a (working) webpage inside of unity using flash? 1 Answer