如何开始在 Visual Studio 中使用 WSDL 文件,它位于项目的根目录中,而不是托管在 Internet 上的某个地方 [英] How can I get started using a WSDL file with Visual Studio it's in the root of the project instead of being hosted on the internet somewhere

查看:22
本文介绍了如何开始在 Visual Studio 中使用 WSDL 文件,它位于项目的根目录中,而不是托管在 Internet 上的某个地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是使用 Web 服务将 Web 表单集成到 Oracle CRM on Demand (Siebel) 中.我收到了 WSDL 以及 Oracle 提供的一些高级文档.

I've been tasked when integrating a web form into Oracle CRM on Demand (Siebel) using web services. I've been given the WSDL, and some high level documentation from Oracle.

好吧,当我尝试将 WSDL 添加为 Web 引用时,我知道我遇到了麻烦,并且被要求输入 URL.我在项目的根目录中有 WSDL 文件,但我不知道如何链接到它.

Well, I knew I was in trouble when I tried to add the WSDL as Web Reference and I was asked to enter an URL. I have the WSDL file in the root of the project, but I have no idea how to link to it.

所以,我想这意味着我需要学习使用 C# 和 Visual Studio 的 Web 服务.我有一个 Safari Books Online 帐户,所以我可以查找大部分内容.

So, I guess that means I need to learn up on web services using C# and Visual Studio. I have a Safari Books Online account, so I can look up most anything.

已经有一段时间了,但我在表单部分还可以.我只是需要帮助连接和使用网络服务.

It's been a while, but I'm OK at the form part. I just need help connecting and using the web service.

编辑 #1: 好的,澄清我的问题:我非常了解如何使用网络服务.我的具体问题是如何获取此 WSDL 文件并对其进行处理.如果 WSDL 托管在其他地方,我可以将其添加为 Web 引用.但是,我在项目本身中有该文件,这就是我遇到的问题.

Edit #1: Ok, to clarify my question: I am well aware on how to use web services in general. My specific question is how take this WSDL file and do something with it. If the WSDL was hosted somewhere else, I could just add it as a Web Reference. But, I have the file in the project itself and that is what I am having problems with.

推荐答案

Web 参考要求提供 URL,但您可以将其指向本地文件.只需将您的 WSDL 的本地文件路径粘贴进去,它就可以工作了.

The web reference asks for a URL but you can point it to a local file. Just paste the local file path of your WSDL in and it should work.

进一步阐明 Web 参考 URL 与访问 Web 服务的 URL

  1. Web 引用 URL 用于生成和更新 WSDL/Web 服务的包装类.它不是运行时用于访问 Web 服务的 URL.
  2. 生成的包装类上的 URL 属性用于在运行时访问实际的 Web 服务.

更新:它应该在 web.config 或 app.config/settings 文件中添加一个类似于以下内容的路径(取决于您的项目类型):

Update: It should add a path in the web.config or app.config/settings file (Depending on your project type) similiar to the following:

<setting name="Namespace_WebReferenceName" serializeAs="String">
        <value>XXX</value>
</setting>

应该映射到生成的 Web 引用包装类中的 URL 属性.您可以通过编程方式修改 URL 属性以指向您想要的任何位置:

Which should map to a URL property in the generated web reference wrapper classes. You can modify the URL property programmatically to point wherever you want:

Dim shipService As ShipService = New ShipService() 'Initialize the service - where ShipService is the Generated WebReference Wrapper CLass
shipService.Url = ConfigurationSettings.AppSettings("FedExOnlineURL")

这篇关于如何开始在 Visual Studio 中使用 WSDL 文件,它位于项目的根目录中,而不是托管在 Internet 上的某个地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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