简体   繁体   English

更改 WCF 参考 Url.Net Core

[英]Changing WCF Reference Url .Net Core

I am attempting to integrate a Web Service into my project, but the problem is I will need to handle this Web Service for multiple environments.我正在尝试将 Web 服务集成到我的项目中,但问题是我需要为多个环境处理此 Web 服务。 I'm using Visual Studios Connected Services tool to connect my service to my project.我正在使用 Visual Studios Connected Services工具将我的服务连接到我的项目。 This auto generates me a ConnectedServices.json file that looks something like this:这个自动生成一个ConnectedServices.json文件,看起来像这样:

"ProviderId": "Microsoft.VisualStudio.ConnectedService.Wcf",
  "Version": "15",
  "ExtendedData": {
    "inputs": [
      "https://someurl/v3/GetUrl-dev.svc"
    ],
    "collectionTypes": [
      "System.Array",
      "System.Collections.Generic.Dictionary`2"
    ],
    "namespaceMappings": [
      "*, GetUrl"
    ],

The problem is that I need to use both a Dev and a Prod environment in my project so I need to be able to reference both Web Services that have the same methods, just one has the Prod Reference Url https://someurl/v3/GetUrl-Prod.svc .问题是我需要在我的项目中同时使用DevProd环境,所以我需要能够引用具有相同方法的 Web 服务,只有一个具有Prod Reference Url https://someurl/v3/GetUrl-Prod.svc

I've tried to Google it and look here as well but the solutions are mostly for ASP.NET applications, mine is a AWS Lambda project so these solutions don't fit me.我试过用谷歌搜索它并在这里查看,但解决方案主要用于 ASP.NET 应用程序,我的是 AWS Lambda 项目,所以这些解决方案不适合我。

I have tried to add the endpoint explicitly like;我试图明确添加端点,例如;

var client = new GetUrlContractClient(new BasicHttpBinding(), new Endpoint("https://someurl/v3/GetUrl-Prod.svc");

An exception gets thrown for including https:// and says that it expects http:// so I remove that and then the Web Service fails.包含https://并说它需要http://所以我将其删除,然后 Web 服务失败。 I have also looked into modifying that JSON file on runtime, but it seems like a bad idea.我还研究过在运行时修改 JSON 文件,但这似乎是个坏主意。

Is there a "standard practice" when it comes to using multiple environments with Connected Services on.Net Core?在使用.Net Core 上的 Connected Services 的多个环境时,是否有“标准做法”?

So as it seems this was the correct way to go about it but in the BasicHttpBinding constructor you have to explicitly say that it is BasicHttpSecurityMode.Transport and now it is working for me!因此,这似乎是 go 关于它的正确方法,但是BasicHttpBinding构造函数中,您必须明确地说它是BasicHttpSecurityMode.Transport ,现在它对我有用!

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

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