我用三种方法制作了一个WCF:
[ServiceContract]
public interface IService1
{
[OperationContract]
String devolverPisosA();
[OperationContract]
String devolverPisosV();
[OperationContract]
String devolverNoticias();
}我需要在baseAddress和EndPoint中定义Web.config文件,但我不知道如何定义:
我正在尝试这个(和一些变体),但这不起作用.(system.serviceModel之间)
<services>
<service
name="ProyectoJosephWCF.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Iservice1/"/>
</baseAddresses>
</host>
<endpoint address="devolverPisoA"
binding="wsHttpBinding"
contract="ProyectoJosephWCF.Service1" />
<endpoint address="devolverPisoV"
binding="wsHttpBinding"
contract="ProyectoJosephWCF.Service1" />
<endpoint address="devolverNoticias"
binding="wsHttpBinding"
contract="ProyectoJosephWCF.Service1" />
</service>
</services>编辑:如果我之前没有定义baseAddress和端点(使用在创建项目时创建的默认配置),并且启动了Services1.svc,我可以通过测试窗口来达到结果json,但是我不能(或者至少我不知道如何)从Android (由Retrofit)获得JSON结果。我假设我配置了Retrofit (baseAddress和Endpoint值错误),所以我决定根据我自己的.为此,我以前在Web.config中设置了代码,但我也联系不到它们.
此外,我还想得到Mozilla的JSON结果(我指的是浏览器),因为有人说我可以帮助我理解我使用的是什么baseAddress和端点.
EDITED2:行为是设置为:
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>仍然无法达到android或浏览器的效果.
发布于 2016-07-11 18:50:38
终于..。如果你需要的话就去看看。
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>和:
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "devolverPisoA")]
List<pisosAlquiler> devolverPisosA();发布于 2016-07-09 14:43:28
您需要设置httpGetEnabled="true"以使WSDL可用,如下所示
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>在服务声明中包括相同的行为配置,如
<service name="ProyectoJosephWCF.Service1"
behaviorConfiguration="NewBehavior">有关详细信息,请参阅serviceMetadata。
https://stackoverflow.com/questions/38282678
复制相似问题