通过 Java 客户端连接到 WCF 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14559505/
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-31 16:40:50  来源:igfitidea点击:

Connect via Java client to WCF Service

c#javawcf

提问by Polaris

I have WCF service which has 2 endpoints: wsHttpBinding and basicHttpBinding. I can connect to each endpoint via C# client.

我有 WCF 服务,它有 2 个端点:wsHttpBinding 和 basicHttpBinding。我可以通过 C# 客户端连接到每个端点。

My Wcf Service configuration

我的 Wcf 服务配置

  <service behaviorConfiguration="App.ServiceBehavior"
          name="MyService">
        <endpoint address="/ws" binding="wsHttpBinding" bindingConfiguration="httpBindingForWs"
           contract="Namespace.IMyService">
          <identity>
            <dns value="127.0.0.1" />
          </identity>
        </endpoint>
        <endpoint address="/basic" binding="basicHttpBinding" bindingConfiguration="httpBindingForBasic"
            contract="Namespace.IMyService">
          <identity>
            <dns value="127.0.0.1" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://127.0.0.1:12000/MyService" />
          </baseAddresses>
        </host>
      </service>

I can generate wsdl in Java. Can you show me sample code, how can I consume basicHttpBinding in Java?

我可以用 Java 生成 wsdl。你能告诉我示例代码,我如何在 Java 中使用 basicHttpBinding?

回答by TheWhiteRabbit

you can consume the webservice using Java there are different frameworks to make your job easier, like AXISand Apache CXF

您可以使用 Java 使用网络服务,有不同的框架可以让您的工作更轻松,例如AXISApache CXF

Look at following article for more pointers on same

查看以下文章以获取更多关于相同内容的提示

Consuming WCF services with Java

使用 Java 使用 WCF 服务