如何将完整实体发送到WCF Restful服务(发布)以进行更新?

时间:2019-01-23 07:17:00

标签: c# rest wcf wcf-rest

使用RestfulServiceMgr类,我能够GetProducts和GetProductById。但是当我需要将整个实体发送到WCF静态服务进行更新时,不确定如何对更新产品执行此操作。

WCF Restful Service:

public interface ContactRepository extends JpaRepository<Contact, Long> 
{
    @Query(value = "Select c.* from contacts c where c.username is not null order by c.id asc limit ?1,  ?2 ", nativeQuery = true)         
    List<Contact> findContacts(int offset, int limit);        
}

使用RestfulServiceMgr类调用Resful服务:

        [OperationContract]
        [WebInvoke(Method = "POST")]
        void UpdateProduct(Entity_Product eProduct);

        [OperationContract]
        [WebInvoke(Method = "POST")]
        void UpdateProductDetails(Entity_ProductDetails eProductDetails);

RestfulServiceMgr固定电话帮助程序类:

  public void UpdateProduct(Entity_Product ProductData, Entity_ProductDetails ProductDetailsData)
    { 
        client.EndPoint = @Constants.Url_UpdateProduct;
        client.Method = HttpVerb.POST;
        client.PostData = "{postData: value}";
        client.MakeRequest();

        client.EndPoint = @Constants.Url_UpdateProductDetails;
        client.Method = HttpVerb.POST;
        client.PostData = "{postData: value}";
        client.MakeRequest();  
    }

1 个答案:

答案 0 :(得分:0)

工程!!!

        client.EndPoint = @Constants.Url_UpdateProduct;
        client.Method = HttpVerb.POST;
        client.PostData = new JavaScriptSerializer().Serialize(ProductData);
        client.MakeRequest();