使用Java Server Page(JSP)消耗WCF [英] Consuming WCF using Java Server Page (JSP)

查看:65
本文介绍了使用Java Server Page(JSP)消耗WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我是WCF的新手,我创建了一个WCF服务,该服务将由JSP页面使用.已经生成了WSDL文件并将其添加到JSP客户端中,但是我已经花了几天时间尝试使其工作,我觉得自己可以从一些咨询中受益.我希望只显示通过WCF服务访问的访问数据库中的一组记录.您能否帮助我实现此功能.我已经提供了WCF服务的代码.

我的WCF代码如下:

Hello Guys

I am new to WCF, I have created a WCF service that will to be consumed by a JSP page. The WSDL file has been generated and added to the JSP client but I have just got to a point where I feel I could benefit from some consultations after having spent days trying to get it to work. I am hoping to just display a set of records from an access database that is accessed through WCF service. Could you please help me to achieve this functionality. I have provided my code for the WCF service.

My WCF Code is as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WCFCarService
{
    [ServiceContract]
    public interface ICarService
    {
        [OperationContract]
        List<Car> GetCars();
    }

    [DataContract]
    public class Car
    {
        private int carID;
        private string carMake;
        private string carModel;
        private string  carTransmission;
        private string carBodyType;
        private int yearManufactured;

        [DataMember(Order = 1)]
        public int CarID { get { return carID; } set { carID = value; } }

        [DataMember(Order = 2)]
        public string CarMake { get { return carMake; } set { carMake = value; } }

        [DataMember(Order = 3)]
        public string CarModel { get { return carModel; } set { carModel = value; } }

        [DataMember(Order = 4)]
        public int Year { get { return yearManufactured; } set { yearManufactured = value; } }

        [DataMember(Order = 5)]
        public string CarTransmission { get { return carTransmission; } set { carTransmission = value; } }

        [DataMember(Order = 6)]
        public string CarBodyType { get { return carBodyType; } set { carBodyType = value; } }
    }
}


我的实现如下:


My implementation is as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WCFCarService
{
    public class CarService : ICarService
    {

        #region ICarService Members

        public List<Car> GetCars()
        {
            List<Car> carList = new List<Car>();

            return carList;
        }

        #endregion
    }

}


非常感谢您的协助.
谢谢,
TB


Your assistance is greatly appreciated.
THANKS,
TB

推荐答案

一分.如果要在Java中使用它,可以将绑定定义为"basicHttpBinding"而不是"wsHttpBinding".
One point. If you''re going to consume this in Java, it is safe to define the binding as "basicHttpBinding" instead of "wsHttpBinding".


好吧,我有一种方法.

那就是在JQuery中调用wcf,然后可以在需要时从JSP激活JQuery代码.

我已经做到了.我正在搜索直接从JSP代码本身进行调用
well, i have got one way to do so.

And that is to call wcf in JQuery and then that JQuery code can be activated from JSP when required.

i have done this. and i am searching to directly call from JSP code itself


这篇关于使用Java Server Page(JSP)消耗WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆