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

大兔子大兔子 提交于 2020-01-04 14:29:52

问题


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.

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.

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.

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.


回答1:


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.

Further Clarification of Web Reference URL vs URL to access Web Service

  1. Web Reference URL is used to generate and update wrapper classes for WSDL/Web Service. It is not the URL used at runtime to access Web Service.
  2. URL property on generated wrapper classes is used to access actual web service at runtime.

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>

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")


来源:https://stackoverflow.com/questions/1677926/how-can-i-get-started-using-a-wsdl-file-with-visual-studio-its-in-the-root-of-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!