首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >定义baseURL和EndPoint

定义baseURL和EndPoint
EN

Stack Overflow用户
提问于 2016-07-09 14:09:20
回答 2查看 589关注 0票数 0

我用三种方法制作了一个WCF:

代码语言:javascript
复制
[ServiceContract]
public interface IService1
{
    [OperationContract]
    String devolverPisosA();

    [OperationContract]
    String devolverPisosV();

    [OperationContract]
    String devolverNoticias();
}

我需要在baseAddressEndPoint中定义Web.config文件,但我不知道如何定义:

我正在尝试这个(和一些变体),但这不起作用.(system.serviceModel之间)

代码语言:javascript
复制
<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:行为是设置为:

代码语言:javascript
复制
<behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

仍然无法达到android或浏览器的效果.

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-07-11 18:50:38

终于..。如果你需要的话就去看看。

代码语言:javascript
复制
<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>

和:

代码语言:javascript
复制
        [OperationContract]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "devolverPisoA")]
        List<pisosAlquiler> devolverPisosA();
票数 0
EN

Stack Overflow用户

发布于 2016-07-09 14:43:28

您需要设置httpGetEnabled="true"以使WSDL可用,如下所示

代码语言:javascript
复制
<behaviors>
 <serviceBehaviors>
  <behavior name="NewBehavior">
    <serviceMetadata httpGetEnabled="true" />
  </behavior>
 </serviceBehaviors>
</behaviors>

在服务声明中包括相同的行为配置,如

代码语言:javascript
复制
      <service name="ProyectoJosephWCF.Service1"
behaviorConfiguration="NewBehavior">

有关详细信息,请参阅serviceMetadata

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38282678

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档