简体   繁体   English

如何将为Java Webservice生成的WSDl转换为C#客户端?

[英]How do I translate a WSDl generated for Java Webservice into a C# client?

I am in .NET environment and I am supposed to reference and consume a java WebService with a WSDL. 我在.NET环境中,应该使用WSDL引用和使用Java WebService。

I am not a wsdl master and neither have I done extensive work in WCF but normally WCF has two kind of binding which are BasicHTTP and WSHTTP but it sounds like I am not able to find any details on this looking at the WSDL. 我不是wsdl专家,我也没有在WCF中做过广泛的工作,但是通常WCF有两种绑定,分别是BasicHTTP和WSHTTP,但是听起来我在WSDL上找不到任何详细信息。 instead I do see something like following: 相反,我确实看到类似以下内容:

<wsdl:port name="SFAPI12" binding="tns:SFAPISoap12Binding">
  <wsdlsoap12:address location="https://api.successfactors.eu:443/sfapi/v1/soap12" /> 
  </wsdl:port>

followed by 其次是

<wsdl:binding name="SFAPISoapBinding" type="tns:SFAPI"><wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

I have no idea how to consume it in my C# application. 我不知道如何在我的C#应用​​程序中使用它。 Any ideas? 有任何想法吗?

Right click the ServiceReference folder in your C# project, click on 'Add new service reference'. 右键单击C#项目中的ServiceReference文件夹,然后单击“添加新服务引用”。 Give the java wsdl and enter an alias name for this service. 输入java wsdl并为此服务输入一个别名。 Once this is done, then you can start using this alias for making client calls to the service. 完成此操作后,您就可以开始使用该别名来对服务进行客户端调用了。

You can use tool svcutil.exe. 您可以使用工具svcutil.exe。 Run from command line: 从命令行运行:

svcutil *.wsdl

It generates ".cs" and ".config" files. 它生成“ .cs”和“ .config”文件。

svcutil.exe usually placed in directory: c:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Bin\\ or similar. svcutil.exe通常位于以下目录中:c:\\ Program Files(x86)\\ Microsoft SDKs \\ Windows \\ v7.0A \\ Bin \\或类似文件。

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

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