How to add service reference from customer's private network - c#

I need to develop a service client application in C#. The service is hosted on customer's local network which I have no access. So I cannot use Add Service Reference option to create service proxy.
The customer gave me only the XML Soap declarations of their service. It looks like the following:
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5.
-->
- <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Oracle JAX-WS 2.1.5.
-->
- <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://helios.tedas.gov.tr/im" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://helios.tedas.gov.tr/im" name="IletisimModulu">
- <types>
It is just the head of XML, I am not putting the full XML because of its size. I think this is what we would see if we navigate to service url from explorer (http://mywebservice/Service?WSDL).
So now, how can I create service proxy from this XML document that they gave me?

So I cannot use Add Service Reference option to create service proxy.
You can paste a file path there as well as an URL. See also How can I consume a WCF service using a local WSDL file?.

Related

Error in Angular app running on .NET Core in Service Fabric

I have created a new service fabric application, added a stateless .NET Core service (.NET Core 2.1) and selected the angular template. It builds fine and all looks OK however when I run it I get this error:
Startup.cs contains a line spa.UseAngularCliServer(npmScript: "start"); which is only used in development, if I remove this line then I no longer get this error but it doesn't pick up any of my changes to code.
I have tried updating my npm, node, angular cli versions, updating the project to angular 7 (it is 5 by default) with no luck.
If I run ng serve directly in the ClientApp folder it runs OK so the issue seems to be to do with it being hosted in .NET Core or SF.
It seems it could be something to do with the SF service not having permissions to create/edit files/folders under system32?
As suspected it was to do with SF not having permission to modify that folder. Service fabric runs under the user NETWORK SERVICE.
I found 2 ways to fix it:
1. Manually grant permission to NETWORK SERVICE
I navigated to C:\Windows\System32\config\systemprofile\AppData\Roaming and edited the permissions in that folder to give the user NETWORK SERVICE permissions to read/write
2. Edit ApplicationManifest.xml to give SF admin permissions
By adding
<Principals>
<Users>
<User Name="LocalAdmin" AccountType="NetworkService">
<MemberOf>
<SystemGroup Name="Administrators" />
</MemberOf>
</User>
</Users>
</Principals>
<Policies>
<DefaultRunAsPolicy UserRef="LocalAdmin" />
</Policies>
Either of these seems to make it work. The best part is all it eventually did is create an empty npm folder there.

Azure: getting service certificate without defining an additional configuration

My cloud service has the following config:
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration ...>
<Role name="...">
<ConfigurationSettings>
<Setting name="MyCertThumbprint" value="AB687DC9F63D51AE6E9522B86B97EFD15F55EA42" />
</ConfigurationSettings>
<Certificates>
<Certificate name="MyCert" thumbprint="AB687DC9F63D51AE6E9522B86B97EFD15F55EA42" thumbprintAlgorithm="sha1" />
</Certificates>
</Role>
</ServiceConfiguration>
See the redundance?
I want to get rid of MyCertThumbprint config. Is there an Azure API that gives me access to the thumbprint of MyCert? Or maybe the X509Certificate2 instance itself (i.e. without having to search for it using X509Store) ?
Sure - if you know other information about the certificate, you can use any of the X509FindType Enumerations with X509Certificate2Collection.Find Method. Unfortunately, the Certificates section of the ServiceConfiguration is for locating the certificate in the Cloud Service certificate store and installing that certificate on the VMs associated with the Role you are deploying. There is no API to access the section directly. So your choice is to hard code something like the certificate subject name or the thumbprint and hope it doesn't change, or add a setting like you've demonstrated in your code sample that is configurable with each deployment.
The ConfigurationSettings section mirrors the appSettings section in the web.config file and when used in conjunction with CloudConfigurationManager.GetSetting("settingsKey") with look first in the ServiceConnfiguration then in the web.config for application settings, allowing you to un local in an emulator or just IIS express and achieve the same functionality. So we duplicate the settings in both ServiceConfiguration and web.config.

Can't get NServiceBus running under custom service account?

I've created a bare-bones NServiceBus endpoint (which doesn't do anything for now), and when I install it (using NServiceBus.Host.exe /install /displayName:"MyEndpoint"), it gets installed as a service
that runs under Local Service, and it works perfectly.
Now, when I change the Run as account for this Windows Service to my own local service account (lets call it "svcTestAccount" for now, it has Logon as a service permission), the service starts and then unexpectedly stops halfway during its initialization.
I can't tell why, since no exceptions get logged to log4net, the process just terminates.
I've seen this behaviour before in a previous project when the endpoint couldn't access the queue it needed, but this time I have configured the 5 queues that my endpoint to give "Everyone" "Full Control", so it shouldn't be that, right?
What's strange is that, when I run it (using the NServiceBus.Host.exe on production profile), it happily runs in all the following situations:
From within Visual Studio 2012, running as local admin.
As a windows service, running under Local Service
As a windows service, running under Network Service
As a windows service, running under svcTestAccount, if svcTestAccount is a member of the local Administrators group.
From a command prompt running under svcTestAccount (i.e. "runas /user:svcTestAccount cmd" to open the command prompt, then NServiceBus.Host.exe to run my endpoint)
The only thing that doesn't work is getting it to run as a Windows Service under svcTestAccount (and not being a member of the local Administrators group).
Can anybody tell me what's going on?
For completeness sake, my endpoint only consists of:
public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
public void Init()
{
Configure.With()
.DefaultBuilder()
.Log4Net();
}
}
And my web.config:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<configuration>
<configSections>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
</configSections>
<UnicastBusConfig>
<MessageEndpointMappings>
</MessageEndpointMappings>
</UnicastBusConfig>
</configuration>
I'm using NServiceBus 4.3.0 on Windows Server 2012.
To run NServiceBus host as a different account (not Local System) you need to execute the installer with /username and /password, eg:
NServiceBus.Host.exe /install /displayName:"MyEndpoint" /username:"mydomain\username" /password:"mysecretpassword"
See http://docs.particular.net/NServiceBus/the-nservicebus-host#installation for more info.

How to configure Kentico CMS to use In-Role Cache

First of all, I'm new to Kentico CMS.
We download the from here. Then install the application as Windows Azure project.
When I look at web.config, Kentico CMS 7 (as of today) uses Shared Caching which has been deprecated a couple of years back.
Is there any way I can configure to use In-Role Cache (or worst case Cache Service which is still in Preview)?
<!-- Azure AppFabric cache BEGIN -->
<section name="dataCacheClients"
type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection,
Microsoft.ApplicationServer.Caching.Core" allowLocation="true"
allowDefinition="Everywhere"/>
<!-- Azure AppFabric cache END -->
<!-- Azure AppFabric cache BEGIN -->
<dataCacheClients>
<dataCacheClient name="default">
<hosts>
<host name="YourName.cache.windows.net" cachePort="22233"/>
</hosts>
<securityProperties mode="Message">
<messageSecurity authorizationInfo="YourKey"/>
</securityProperties>
</dataCacheClient>
<dataCacheClient name="SslEndpoint">
<hosts>
<host name="YourName.cache.windows.net" cachePort="22243"/>
</hosts>
<securityProperties mode="Message" sslEnabled="true">
<messageSecurity authorizationInfo="YourKey"/>
</securityProperties>
</dataCacheClient>
</dataCacheClients>
<!-- Azure AppFabric cache END -->
The host element in the caching configuration points to a caching cluster and it doesn't care about how the cache cluster is deployed - old service, new service or in-role.
If you use the new Caching service you should be able to change the configuration to point at your cache instance using your cache's URL
To use in-role caching you will need to create the relevant load-balanced endpoints for the cloud service and then configure your client with your cloud service URL.
I found the article in Kentico site, so I posted for others -
Windows Azure Cache Service in Kentico CMS
If you used AppFabric caching in your Kentico CMS projects running on Azure, you could be interested in replacing this caching option with a new Windows Azure Cache because AppFabric cache is no longer provided.
To make it work, you should follow the official guide from Azure documentation - How to Use Windows Azure Cache Service (Preview).
After initially creating the cache and configuring it, you need to open your project in Visual Studio and install Windows Azure Caching NuGet package for CMSApp web role as it is mentioned in the guide.
Another step is to remove xmlns attribute from tag in your web.config file, replace the original and tags with the newly added ones and delete duplicate tag.
The next thing to do is to remove xmlns attribute for tag as well, put tag to the original section and delete the duplicate.
The rest of the steps should correspond to those mentioned in the guide, i.e. replacing [Cache role name or Service Endpoint] with the endpoint, which is displayed on the Dashboard in the Azure Management Portal.
The guide also contains sample codes for creating and retrieving objects from the cache, specifying expiration, storing ASP.NET session state, etc.

WCF cross-domain policy security error

I am using VSTS 2008 + C# + WCF + .Net 3.5 + Silverlight 3.0. I host Silverlight control in an html page and debug it from VSTS 2008 (press F5, then run in VSTS 2008 built-in ASP.Net development web server), then call another WCF service (hosted in another machine running IIS 7.0 + Vista). The WCF service is very simple, just return a constant string to client.
When invoking the WCF service from Silverlight, I got the following error message,
An error occurred while trying to make a request to URI 'https://LabTest/Test.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
Here is the clientaccesspolicy.xml file, anything wrong?
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*">
</domain>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"></resource>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
This may be a shoot in the dark. But I recall running into a similar scenario setting up a WCF service locally on vista and IIS7. as it turned out i had to add some lines into my web.config file more specifically with the baseAddressPrefixFilters, Read this other post : Here . I had a problem because my default website had more than one host binding. it would take *:80 and www.mydomain.com:80 and WCF would not like that.
I had a similar problem but my solution was a lot simpler.
In my clientConfig file, my end point addresses for my different services had different URL's.
Some had local host and some had my machine's name in the URL.
Once I made all of them use local host it fixed my problem.
one idea could be to use fiddler and find the request which is requesting crossdomainpolicy xml. Is that failing? Check the address it is pointing to. I debugged my issue using that. It was pointing to root of the server and my crossdomainpolicy xml was in WCF project folder.

Categories

Resources