在 URL 中键入什么以在部署后访问 WCF Web 服务

What to type in URL to access WCF web-service after deploying it

我已经将 wcf 网络服务部署到 AppHarbor(免费的 asp.net 网络托管服务)。他们已经在 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);
    }
}

我有 2 个问题。

  1. When I type http://pizzaapp.apphb.com/Service1.svc/Login/123/1 in browser. Why don't I get anything? (I see a blank page) Whereas I should be seeing a response of either true or false (Login successfull or not for example).

  2. When I try the above url using android app as client. I get a file not found exception. Why is it so? I used following android code to work as client. (Note that I've tested my wcf webservice on visual studio and it was working fine).

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 中提供我的界面和网络服务 class 的名称。