简体   繁体   English

如何通过ASP.NET网站中的WCF服务传递值

[英]How to pass values through a WCF Service in a ASP.NET Website

I am working on a Outlook Addin for our Website. 我正在为我们的网站开发Outlook插件。 I want to pass the selected date, time and subject from outlook calender to our website which loads in a webcontrol inside Outlook. 我要将选定的日期,时间和主题从Outlook日历传递到我们的网站,该网站会加载到Outlook内部的WebControl中。 The Webservice is WCF. Web服务是WCF。

I can transfer the calender values to WCF like this: 我可以像这样将日历值传输到WCF:

 [OperationContract]
string getBookingURL(string guid, BookingRequest request,string token,string exitURL);

BookingRequest is the class where i pass the calender values: BookingRequest是我传递日历值的类:

[ServiceContract]
public class BookingRequest
{
    public long bookingID { get; set; }
    public DateTime startUTC { get; set; }
    public DateTime endUTC { get; set; }
    public string subject { get; set; }
    public int numParticipants { get; set; }
}

now the next step would be something like this on my asp.net Website: 现在下一步将是这样的事情在我的asp.net网站上:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

if (BookingRequest!=Null) then
FromDateTextfield.Text = BookingRequest.startUTC
ToDateTextfileld.Text = BookingRequest.EndUTC
SubjectTextfield.Text = BookingRequest.subject
End If

End Sub

The problem is that I don't know how to pass the Values from WCF to the Webpage on load. 问题是我不知道如何在加载时将值从WCF传递到网页。

Maybe there is a solution without WCF. 也许有没有WCF的解决方案。 Could you help me to solve this problem? 您能帮我解决这个问题吗?

i am assuming that you have created proxy class on client side. 我假设您已经在客户端创建了代理类。 so using the object you can call service using proxy object. 因此使用该对象可以使用代理对象调用服务。 as bellow: 如下:

 ProxyServClient client = new ProxyServClient();
 BookingRequest bookingrequest = client.GetBookingDetails();
 if(BookingRequest!=Null)
  {
    FromDateTextfield.Text = BookingRequest.startUTC;
    ToDateTextfileld.Text = BookingRequest.EndUTC;
    SubjectTextfield.Text = BookingRequest.subject;
  }

for this you have to create Booking request property class which has properties as your service is going to return. 为此,您必须创建预订请求属性类,该类具有随服务返回的属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM