以下是代码
我尝试了这个调用,但它没有工作......即使这个调用中的函数是空的我尝试了这个确切的函数调用只有5个输入参数,它工作吗? 希望有人可以建议你有什么东西是可疑的,如果你有,我可以最小化这个代码,这意味着参数随时可以通过我的建议。
以下代码:
[WebInvoke(UriTemplate = "customer/update/customerCode={customerCode}/customerName={customerName}/customerCountry={customerCountry}/customerTelephone={customerTelephone}/customerEmail={customerEmail}/customerCreditLimit={customerCreditLimit}/customerCommission={customerCommission}/customerRank={customerRank}/contactFullname={contactFullname}/contactBusinessPhone={contactBusinessPhone}/contactTimezone={contactTimezone}/contactActive={contactActive}/contactDepartment={contactDepartment}/contactHomePhoneExtension={contactHomePhoneExtension}/shipToCountry={shipToCountry}/shipToPaymentTerm={shipToPaymentTerm}/shipToCommissionPercent={shipToCommissionPercent}/shipToTruckSize={shipToTruckSize}/shipToTaxNumber={shipToTaxNumber}/shipToRouteCode={shipToRouteCode}/shipToOpenTime={shipToOpenTime}/shipToCloseTime={shipToCloseTime}", Method = "PUT", BodyStyle = WebMessageBodyStyle.Wrapped)]
public void UpdateCustomer(string customerCode, string customerName, string customerCountry, string customerTelephone, string customerEmail,
string customerCreditLimit, string customerCommission, string customerRank, string contactFullname,
string contactBusinessPhone, string contactTimezone, string contactActive, string contactDepartment,
string contactHomePhoneExtension, string shipToCountry, string shipToPaymentTerm, string shipToCommissionPercent,
string shipToTruckSize, string shipToTaxNumber, string shipToRouteCode, string shipToOpenTime,
string shipToCloseTime)
{
// code or no code
}
这就是我实现上述功能的方法:
using (HttpResponseMessage response = m_RestHttpClient.Put("customer/update/customerCode=CUST190/customerName=Ralph Lauren/customerCountry=United Kingdom/customerTelephone=1234567489/customerEmail=ralph@lauren.com/customerCreditLimit=1/customerCommission=5/customerRank=45/contactFullname=Diego Sin/contactBusinessPhone=911/contactTimezone=6/contactActive=True/contactDepartment=Sales/contactHomePhoneExtension=456/shipToCountry=Uganda/shipToPaymentTerm=NET30/shipToCommissionPercent=1/shipToTruckSize=50/shipToTaxNumber=777/shipToRouteCode=001/shipToOpenTime=10 am/shipToCloseTime=11pm", frm.CreateHttpContent()))
{
response.EnsureStatusIsSuccessful();
}
谢谢
答案 0 :(得分:2)
你没有身体参数,PUT需要一个身体。
除此之外,PUT并不等同于执行Update存储过程。不要试图这样做,这没有任何意义。所有这些参数都需要在体内。
网址长度存在物理限制,因此您可能会遇到问题。