使用 Java 客户端使用 wcf 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7544685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 20:25:13  来源:igfitidea点击:

Consume a wcf Service with a Java Client

javawcfweb-servicessoapsvc

提问by user963451

I try to consume a wcf service hosted on an iis with a simple java client.

我尝试使用一个简单的 java 客户端使用托管在 iis 上的 wcf 服务。

my service is a basicHttpService.

我的服务是一个基本的HttpService。

now my Question. What do i need in java to access the service methods?

现在我的问题。我在java中需要什么来访问服务方法?

i build a little example:

我建立了一个小例子:

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


namespace android.Web
{
    [ServiceContract]
    public interface ITestService
    {
        [OperationContract]
        void DoWork();
        [WebGet(UriTemplate = "Login/")]
        String Login();
    }
}

the login Method only returns a simple string that want to test in my java client. I tried some tutorials found in the internet, but nothing wokrs ;)

login 方法只返回一个想要在我的 java 客户端中测试的简单字符串。我尝试了一些在互联网上找到的教程,但没有任何效果;)

thx alot.

多谢。

回答by Shiraz Bhaiji

I do not think that your problem is due to a Java client.

我不认为您的问题是由于 Java 客户端造成的。

You are using basicHttpBinding, at the same time you are using a WebGet attribute which points to using REST and webhttpbinding.

您使用的是 basicHttpBinding,同时您使用的是指向使用 REST 和 webhttpbinding 的 WebGet 属性。

Try making sure that it works from a windows WCF client first.

首先尝试确保它可以从 Windows WCF 客户端运行。