简体   繁体   中英

Deployment of C# project and adding web service reference at the time of installation

I have a requirement in which, application will be referenceing a web service. With each new client installation I need to update the reference manually by opening the project in VSS and re-adding the reference.

Can I make addition of reference as a part of my installation project or I can add/update the web service reference through code in C#.?

I have no experience with creating a setup or msi project. If someone can also point me to a good tutorial then it will be great..

Just a clarifiction for Service is not changing, Service will be hosted on differnt mahcine,so every time URI is changed.

Snippet from app config: I need to update the endpoint and servicePrincipalName through code or setup project?

  <endpoint address="net.tcp://rntn1099:8201/AX/Services/APVendInvoice"
  binding="netTcpBinding" bindingConfiguration="NetTcpBinding_VendVendInvoiceService"
contract="VendInvoiceService.VendVendInvoiceService"     name="NetTcpBinding_VendVendInvoiceService"><identity>  < servicePrincipalName value="host/RNTN1099.corp.xyz.com" />

I have never heard this as an actual requirement. I have heard it from people who don't know that you can choose the URL of the service at runtime.

When you update the service reference, you are actually changing the code of the client. This means, at the very least, that all of your tests of the client should take place after the reference update (so that you are testing the code that the client uses).

When you use "Add Service Reference", at the bottom you enter a Namespace. That will combine with the default namespace for your application to be the namespace in which several classes are created. For example, if your default namespace is "MyWebApp", and you use "RemoteService" as the namespace in "Add Service Reference", then the namespace will be MyWebApp.RemoteService . You can examine the contents of this namespace by using "View->Object browser" in Visual Studio.

Now, if the service is named "OrderService", then there will be a class named OrderServiceClient. It has several constructors. One of those constructors accepts both the configuration name and the URL. Another accepts a configuration name and an EndPointAddress . You should use one of the two.

That requirement sounds strange. Why do you have to update the reference? If the service would change it's interface, your client would not work anymore. So I assume that your problem is, that you want to access the same service under a differnt url?: If yes. You don't have to update the reference. You can configure the service URl without updating the reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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