小编DJI*_*ave的帖子

我可以在本地调用自托管WCF服务中的方法吗?

我有一个WCF服务合同,基本上是发布订阅者模式.

WCF服务托管在我要发布的Windows服务中.客户端订阅消息,当Windows服务执行某些操作时,它会发布给所有客户端.

为了托管服务,我已经声明了一个ServiceHost类,而Contract Class有一个方法,该方法没有在接口中标记,而是在要发布的类中实现.

我希望能够在本地调用此方法(不通过WCF),然后通过Callbacks发布消息.

我似乎无法从ServiceHost获得Contract Class的实例.

这有可能吗?如果可以的话怎么样?我知道解决方法是将一个客户端内置到服务中,但创建一个连接到自身的客户端似乎有点奇怪.

提前致谢

DJIDave

的app.config

<system.serviceModel>
    <services>
      <service behaviorConfiguration="Processor.Wcf.ServiceBehavior"
        name="Processor.Wcf.ProcessorService">
        <endpoint address="net.tcp://localhost:9000/processor/service"
              binding="netTcpBinding" name="procService"
              bindingConfiguration="netTcpBindingConfig"
              contract="Processor.Wcf.IProcessorService"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          <host>
            <baseAddresses>
              <add baseAddress="http://localhost:8732/Design_Time_Addresses/Processor.Wcf/Service1/" />
            </baseAddresses>
          </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Processor.Wcf.ServiceBehavior">
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set …
Run Code Online (Sandbox Code Playgroud)

.net c# wcf servicehost

10
推荐指数
1
解决办法
7630
查看次数

.Net Core Web API Bearer 颁发者无效

我已经根据最新的 Microsoft 模板编写了 Blazor WASM 应用程序。在开发模式下,一切都很好,但将其发布到 Azure 应用服务后,在调用 API 时,我随机收到 401 未经授权,查看返回的标头

WWW-Authenticate: Bearer error="invalid_token", error_description="The issuer 'https://*domain*.azurewebsites.net' is invalid"
Run Code Online (Sandbox Code Playgroud)

这是当客户端使用 https://.azurewebsites.net 客户端时。所以它与Web API相匹配。

我还有一个附加到应用程序服务的自定义域,这意味着还有 https://www. 域名.co.uk 和 https://域名.co.uk 均采用 SSL。

我已检查 JWT 令牌,它包含我正在调用的网站版本的正确 URL。

有时一切正常,但 60% 的情况下允许用户登录,然后 API 调用失败。我似乎无法跟踪 1 个域名或模式(例如过期登录)。如果您注销然后重新登录,并不能解决问题。

配置看起来像这样

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseDatabaseErrorPage();
            app.UseWebAssemblyDebugging();
        }
        else
        {
            app.UseExceptionHandler("/Error");
        }

        app.UseHttpsRedirection();
        app.UseBlazorFrameworkFiles();
        app.UseStaticFiles();

        app.UseRouting();

        app.UseIdentityServer();
        app.UseAuthentication();
        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapRazorPages();
            endpoints.MapControllers();
            endpoints.MapFallbackToFile("index.html");
        }); …
Run Code Online (Sandbox Code Playgroud)

jwt identityserver4 blazor webapi

5
推荐指数
1
解决办法
805
查看次数

标签 统计

.net ×1

blazor ×1

c# ×1

identityserver4 ×1

jwt ×1

servicehost ×1

wcf ×1

webapi ×1