I have a WSDL file on disk and loaded as a web reference. The problem is that the web reference itself is looking for the WSDL on my machine (using an absolute path), which obviously won't work on teammates' machines.
Is it possible to have the web reference look for the WSDL with a relative path, or from the Resources file? The WSDL is for a third-party service that we've modified to add some extra fields (per their recommendation).
When you add a service reference to the WSDL file on your machine, it gets copied into your "Service References" folder in your project. At that point, the API for your service is determined. There is a "Reference.svcmap" (XML) that is created that holds the location of the original location of the WSDL file. This is so that you can update the service reference in your project if the API changes. But, even without having that original WSDL file you can check in the code and your team can use it without issue. But, if you want them to be able to update the service if the API changes, then you need to actually host that WSDL file in a publicly accessible place. Usually, the web service itself provides the WSDL file and you wouldn't have it on your file system. If you plan to update and change the web service, you should connect to the WSDL hosted on a development web server. That's really where it belongs, and not a local file. But, there's no reason your local file reference wouldn't work just fine until someone tried to update it. If your web service never changes, you've got no problem. If it could change, then host it somewhere and reference a real URL.
My initial testing of tweaking the XML in Reference.svcmap file to try for relative path references did not work, but if you decide you really want to get this to work as your question describes, this is the place to make your attempt.
My suggestion would be to create a programmatic proxy using the cmd line tool wsdl.exe or svcutil.exe to create the .cs or .vb proxy that you could then add to the solution.
This allows for not needing the wsdl file at all. See more information on how here for .NET 2.0 http://msdn.microsoft.com/en-us/library/7h3ystb6(v=vs.80).aspx
for .NET 3.5 or later and svcutil look here: http://msdn.microsoft.com/en-us/library/aa751905.aspx
Related
I downloaded both sample code and WSDL files on the website.
I checked that there are some text documents inside of WSDL folder.
It was based on SOAP, but I don't know how to apply.
How do I apply for SOAP file in the sample code?
It seems like the example queries.
Could you tell me how to do?
you actually do not want to think about the other files in that same folder where your WSDL is located. Just add a Web Reference to your project and direct it to your WSDL. This should add a reference to your project under which you will see all these other files. WSDL will automatically refer those files when needed.
i just need to know that after creating web service proxy if i delete wsdl file then is there will be any problem for creating web service class related instance?
so guide what i need to do after deleting wsdl file from VS2010 IDE as a result there will be no problem to call web service.
my first question was about web service(ASMX) file. so my question is still same but what i need to do in case WCF service. because there is also wsdl file generate after creating proxy. if i delete wsdl file in this case also so how could i make a call to wcf service.
please explain in details.
WSDL file is describes your service operations. In order to generate client Proxies, WSDL file is used.
After you finished creating client proxy, you do not need WSDL file anymore. In fact, it is a good practice to delete or restricting access to WSDL file is a good practice in terms of security.
So you will not need WSDL file, unless you make changes to the service, such as adding a new operation or deleting an existing one. In this case, WSDL file is need to update the client again.
When you add a Service Reference, Visual Studio creates a file called Reference.svcmap inside the Service References/<service name>/ folder, which describes your service. It contains links to the various metadata sources and the configuration options that you used when creating the Service Reference ("Configure Service Reference" from the context menu).
This Reference.svcmap is the only file that you must not delete. When you right-click your Service Reference and select "Update Service Reference" from the context menu, Visual Studio will re-download all the required metadata from their upstream sources, re-create the client proxy and update your app.config file.
From the Service References/<service name> directory, the client proxy Reference.cs is the only file that's actually used when compiling your client app (so you shouldn't delete this either, though Visual Studio will automatically re-generate it for you) - none of these files are used at runtime.
This article also explains what all these files are about:
http://scottseely.com/2009/01/26/misunderstood-add-service-reference/
I have a Windows Service that I'm creating and I'm wondering what options are available in order for me let developers configure the service.
The service is part of an over all larger open source project and hence the service is going to be installed on lots of different machines.
Normal I would use a web/app.config for this but I'm not sure if this is possible.
Hence I am looking to so how others handle this case.
you do as you expect. You use the app.config, which will be renamed to <exeName>.configwhen the project is built and then <exeName>.config will be read by the service called <exeName>.
Settings are applied in a layered way and may come from other configuration files on the machine, such as machine.config. You can read about how configuration is handled on MSDN
EDIT
In response to comment: A service will only read the config when it starts (for perf reasons). If you want to reload the config file later, you need to handle that yourself I think.
You could read the last modified date/time of the config file to determine if the file has been changed, or setup a file system watcher and then tell the configuration manager to reload that section again next time it is read, by calling ConfigurationManager.RefreshSection("appSettings") and that section will be reloaded from disk when you next access it. See the ConfigurationManager MSDN docs
You can just use a .config file with the same name as the exe that is the service.
If your service runs as MyService.exe, it's config file would be MyService.exe.config.
In Visual Studio, just add an Application Configuration file. This will add an app.config file to the project.
You can then access things like AppSettings and ConnectionStrings using the ConfigurationManager class, just like you do with ASP.Net applications.
Im using VB6 in a project and I've some .Net dlls to handle document transfers.
In one of these dlls im calling a webservice to retrieve my documents. This code works if only run as .net project, however running from vb6 it gives me the following error:
"Could not find endpoint element with name "DocServiceSoap' and contract 'documentWebService.DocServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element"
I've googled around and tried everything, e.g. copying from app.config to web.config, specifying endpoint name when calling for service, still no luck :/
Any ideas?
I guess your app.config is called myDotNetDll.dll.config? That's wrong. The config file always need to be attached to the executable file.
So, to solve your issue, you need to copy it to your VB6 application, i.e., it should be called myVb6Application.exe.config and located in the same directory as your myVb6Application.exe.
I have a WCF Service and Client DLL which has the proxy class for my WCF Service. My client dll is going run by a different exe. I have restrictions in adding my client app.config file to the exe location. I cannot do this myExe.exe.config. I want to load the client app.config file in the client dll itself or the app.config file should be loaded from a different location.
And my exe is C++.
Is there any way to do this?
To explicitly load a particular config, you need to launch the object in a separate AppDomain. Use one of the AppDomain.CreateDomain overloads that takes an AppDomainSetup where you can pass in the path to the config file. Yout need to make sure any return values can be marshalled across AppDomain boundaries. No, there isn't an easier way to do this that I am aware of.
This is actually a standard issue with .NET. In general, when you create a separate project which will build into a dll, you can create settings in an app.config file. These settings are not automatically made part of the web.config of the application which uses the DLL.
The "solution" has always been: copy and paste from your library's app.config and paste into the app.config or web.config of the consuming application.
This actually makes a certain amount of sense: these configuration settings are meant to be changed based on the environment in which the code is executing. One set of configuration for your WCF client, stored in a single location, brings us back to the days of the registry.