【发布时间】:2014-01-24 06:45:20
【问题描述】:
我浏览了很多文章和问题,但我无法解决我的问题。我是 Fiddler 的新手,不知道如何使用它。我想将 List ob 对象作为输入传递给我的 WCF REST 服务。
这是我的服务接口:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "LeadStage",
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare)]
Result AddLeadStage(ReqLeadStage[] rls);
这是我的 ReqLeadStage 课程。
public class ReqLeadStage
{
public string Id { get; set; }
public string Name { get; set; }
public string Comments_Remarks__c { get; set; }
public string Entry_Point__c { get; set; }
public string Exit_Point__c { get; set; }
public string IsActive { get; set; }
public string Sequence_No__c { get; set; }
public string Stage_Description__c { get; set; }
public string CreatedById { get; set; }
public string CreatedDate { get; set; }
public string LastModifiedById { get; set; }
public string LastModifiedDate { get; set; }
}
这是我的 Web.Config
<system.serviceModel>
<services>
<service name="SalesForceWCF.SalesForce" behaviorConfiguration="">
<endpoint address="" behaviorConfiguration="RESTBehavior"
binding="webHttpBinding" contract="SalesForceWCF.ISalesForce"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RESTBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
这是我的Result类:
[DataContract]
public class Result
{
[DataMember]
public int CODE { get; set; }
[DataMember]
public string STATUS { get; set; }
[DataMember]
public string DESCRIPTION { get; set; }
}
这是我从 Fiddler 中调用它的方式:
还有 JSON:
[ { "attributes" : { "type" : "Lead_Stage__c", "url" : "/services/data/v29.0/sobjects/Lead_Stage__c/a009000000Rmb3wAAB" }, "Name" : "Discovery", "LastModifiedById" : "005900000028VWrAAM", "CreatedById" : "005900000028VWrAAM", "CreatedDate" : "2013-12-23T10:22:48.000+0000", "LastModifiedDate" : "2013-12-23T10:22:48.000+0000", "Id" : "a009000000Rmb3wAAB" }, ...... ]
这是一张完整的图片 我如何发送我的请求!
这是错误:
400 错误请求错误。我无法追踪它。
谢谢!
【问题讨论】:
-
您也可以使用
RestClientMozilla 插件进行尝试。通过那个尝试。我不确定提琴手。我可以帮助从这里下载它addons.mozilla.org/en-US/firefox/addon/restclient -
你可以试试 Mozilla。下载吧,伙计。它是免费的!
-
它不工作!同样的错误:400 Bad Request!我不知道我哪里做错了。
-
响应正文中是否有任何内容??
-
是的,您将在 Visual Studio 上工作,然后在调试模式下运行 API,当您从 REST 客户端提交请求时,它将 gp 到起点。
标签: c# wcf rest fiddler wcf-rest