Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
托管wcf应用程序并从Android设备访问它,如何做到这一点?_Android - Fatal编程技术网

托管wcf应用程序并从Android设备访问它,如何做到这一点?

托管wcf应用程序并从Android设备访问它,如何做到这一点?,android,Android,如何在iis中托管wcf应用程序并从Android设备访问它以获得json?我需要在iis中托管一个wcf应用程序,并通过android设备访问它,如何做到这一点?有很多相关教程。。我正在为你写一份教程清单 (一) (二) 来自某些stackoverflow答案的一些代码片段 [ServiceContract(Namespace="http://mycompany.com/LoginService")] public interface ILoginService { [Operatio

如何在iis中托管wcf应用程序并从Android设备访问它以获得json?我需要在iis中托管一个wcf应用程序,并通过android设备访问它,如何做到这一点?

有很多相关教程。。我正在为你写一份教程清单

(一)

(二)

来自某些stackoverflow答案的一些代码片段

[ServiceContract(Namespace="http://mycompany.com/LoginService")]
public interface ILoginService
{
    [OperationContract]
    string Login(string username, string password);
}
The implementation of the service could look like this:

public class LoginService : ILoginService
{
    public string Login(string username, string password)
    {
        // Do something with username, password to get/create sessionId
        string sessionId = "12345678";

        return sessionId;
    }
}
You can host this as a windows service using a ServiceHost, or you can host it in IIS like a normal ASP.NET web (service) application. There are a lot of tutorials out there for both of these.

The WCF service config might look like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>


    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="LoginServiceBehavior">
                    <serviceMetadata />
                </behavior>
            </serviceBehaviors>
        </behaviors>

        <services>
            <service name="WcfTest.LoginService"
                     behaviorConfiguration="LoginServiceBehavior" >
                <host>
                    <baseAddresses>
                        <add baseAddress="http://somesite.com:55555/LoginService/" />
                    </baseAddresses>
                </host>
                <endpoint name="LoginService"
                          address=""
                          binding="basicHttpBinding"
                          contract="WcfTest.ILoginService" />

                <endpoint name="LoginServiceMex"
                          address="mex"
                          binding="mexHttpBinding"
                          contract="IMetadataExchange" />
            </service>
        </services>
    </system.serviceModel>
</configuration> 
[ServiceContract(命名空间=”http://mycompany.com/LoginService")]
公共接口ILoginService
{
[经营合同]
字符串登录(字符串用户名、字符串密码);
}
该服务的实现可能如下所示:
公共类登录服务:ILoginService
{
公共字符串登录(字符串用户名、字符串密码)
{
//使用用户名、密码获取/创建会话ID
字符串sessionId=“12345678”;
返回会话ID;
}
}
您可以使用ServiceHost将其作为windows服务宿主,也可以像普通ASP.NET web(服务)应用程序一样在IIS中宿主。对于这两个方面,都有很多教程。
WCF服务配置可能如下所示:

关于代码项目还有一个不错的教程

如果您完成了WCF部分,那么上面的链接对您来说就没有多大用处了,下一部分对您来说将非常有用


的可能重复,但我还无法使用IIS托管WCF服务,这是主要问题。那么您的问题应该是
如何使用IIS托管WCF服务?
。问题你可以很容易地找到答案。。。因为互联网上有很多关于这方面的教程。之后,您的第二个问题将是
如何从Android访问它?
,答案在我指出的stackoverflow问题中。请阅读stackoverflow的规则。你真的应该每个问题问一个问题。在问问题之前先搜索一下。