部署WCF web服务后,要在URL中键入什么以访问它
本文关键字:什么 访问 URL web WCF 服务 要在 部署 | 更新日期: 2023-09-27 18:00:53
我已经向AppHarbor
(一个免费的asp.net web托管服务(部署了一个wcf web服务。他们已将我的应用程序部署在http://pizzaapp.apphb.com.该Web服务有2个OperationContracts
登录和注册,如下所示。
namespace WcfServicePizza
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract(Namespace="http://pizzaapp.apphb.com/")]
public interface IService1
{
[OperationContract]
[WebInvoke(UriTemplate="SignUp",
Method="POST",
BodyStyle=WebMessageBodyStyle.WrappedRequest,
ResponseFormat=WebMessageFormat.Json,
RequestFormat=WebMessageFormat.Json)]
bool SignUp(Customer customer);
[OperationContract]
[WebGet(UriTemplate="Login/phoneNo/password",
BodyStyle=WebMessageBodyStyle.WrappedRequest,
RequestFormat=WebMessageFormat.Json,
ResponseFormat=WebMessageFormat.Json)]
bool Login(string phoneNo, string password);
}
}
我有两个问题。
当我键入http://pizzaapp.apphb.com/Service1.svc/Login/123/1在浏览器中。为什么我什么都没得到?(我看到一个空白页面(而我应该看到一个正确或错误的响应(例如登录成功与否(。
当我使用android应用程序作为客户端尝试上述url时。我收到一个未找到的文件异常。为什么会这样?我使用以下android代码作为客户端工作。(注意,我已经在visualstudio上测试了我的wcf网络服务,它运行得很好(。
try{
URL url = new URL(uri);
Log.d("imaq","URI: "+uri);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod(requestPackage.getMethod());
StringBuilder sb = new StringBuilder();
bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
Log.d("imaq","Going fine");
String line=null;
while ((line=bufferedReader.readLine())!=null){
sb.append(line+"'n");
Log.d("imaq", "Appending: "+line);
}
return sb.toString();
} catch (MalformedURLException e) {
Log.d("imaq", "Exception: "+e.toString());
e.printStackTrace();
return null;
} catch (IOException e) {
Log.d("imaq", "Exception: "+e.toString());
e.printStackTrace();
return null;
}
如果你还需要什么,请告诉我。
Web.config文件出现问题。
我将Web.config与http://www.codeproject.com/Articles/613097/WCF-RESTful-services-and-consuming-them-in-an-HTML我知道我必须在Web.config中提供我的接口和webservice类的名称。