我意识到还有其他职位提出了类似的问题,但没有回答我的问题。我很抱歉,如果这是不够的信息,格式化关闭,或者什么都不。这是我第一次发布。如何将asp.net web服务器连接到iPhone
基本上我的团队正在做一个iPhone应用程序,需要与我们的sql服务器数据库接口。但是因为他们不能直接与对方通话,所以我们正在实现一个接受XML的asp.net媒体,而且显然需要输出JSOD。目前我有一个使用“工作”代码编写的.asmx(代码内的测试字符串)。现在我只是试图从iPhone接受XML。我觉得我们在他的末端(iPhone)或我的末端(.asmx)缺少一些东西。希望你有聪明的头脑可以填补我的空间,因为我们的综合研究......我觉得缺少一些东西。也许我错了,我们已经有我们的东西在一起,这将是非常棒的。
显然这是他需要的所有(根据他的研究)他的目的是为了连接和传输信息。显然它不是.asmx,但它的扩展权应该没有关系?
NSURL *url = [NSURL URLWithString:@"http://myurl.com/RequestHandler.ashx"];
这里是我和我的.asmx代码(注意功能就是肉是)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Xml.Linq;
namespace Outbreak_Mobile
{
[WebService(Namespace = "http://OutbreakMobile.net/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod (Description="To intake an xml package from iPhone and store it")]
public string iPhoneLocation(string xml)
{
//test string to output to screen
string location = null;
//test string of xml to be parsed
//will be converting next line to parse input xml
//string xml = @"<Player>
// <Latitude>42.13245465</Latitude>
// <Longitude>11.11111111</Longitude>
// </Player>";
//line to parse document
//xdocument doc = xdocument.parse(incoming xml)
XDocument doc = XDocument.Parse(xml);
//grabs the information inside <player> tags
XElement loc = doc.Elements("Player").SingleOrDefault();
if (loc != null)
{
var lat = (double)loc.Element("Latitude");
var lng = (double)loc.Element("Longitude");
location = "Lat: " + lat + '\n' + "Long: " + lng;
}
//this is what puts out to the screen
return location;
}
}
}
当前字符串“位置”的产量只是功能测试并且当我知道我正确接收包装时将发生变化。我们错过了什么以便彼此连接?
谢谢大家提前!
在asp.net方面呢?是否缺少任何东西以便从iPhone中获取数据?我猜它必须消耗它之前,它进入函数......谢谢你的快速回复btw :) – 2011-12-17 04:40:10