Using IIS ARR to route SOAP requests - c#

The situation is that we have some SOAP (asmx) services that are version dependent upon a 3rd party software. These services reside on domainA.
We are in the process of migrating to a new version of the 3rd party software where the existing SOAP services will not be able to reside because of a version incompatibility. Currently the upgraded stuff lives on temp.domainA.
We are developing new services to replace the old SOAP services and will plug in wcf routing or something to save us from the next 3rd party version upgrade party.
Ideally, once temp.domainA is all ready to go we will switch that dns to be domainA and change the old domainA to be old.domainA there for breaking all existing applications referencing the soap services.
I've been fooling around with IIS and ARR matching on a common naming convention that the soap services have and trying to have those requests routed. This works very well for Get requests but not so well for POST requests which is what soap uses.
I set up a little test by having 2 identical services running, one on a test server and one on my local machine. The one on my local machine returns different data than the one on the test server so I can tell which one is being invoked.
I set up ARR's proxy in my local iis to be a reverse proxy to the service on the test server. I set up a url rewrite rule to inspect the incoming requests based on the naming convention of the soap service url.
If I browse to the soap endpoint via a browser and httpget's everything works as planned. I get a response from the remote test server with the request originating from localhost.
When I run the test app which makes the same call except as a post with soap I get this error
exception.message: There was no endpoint listening at http://localhost/webservice/Default.asmx that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
exception.InnerException: The remote server returned an error: (404) Not Found.
my settings
and then for Proxy Type i have
use url rewrite to inspect checked
enable ssl offloading checked
and reverse proxy: set to remote.test.server

Related

Test Local Service Against Production Clients

At our company we have a variety of microservices and web clients that make up our SaaS (software as a service) product.
When modifying the behavior of a specific service (usually written in C# WebApi). We would like to spot check the integration behavior against a client that makes calls to that service. As the developer working on a C# service locally, I would prefer not to have to clone and build that specific web client (with local settings to point to the local server) in order to see how it interacts with my local server changes. Ideally I could navigate to a deployed version of the client (develop, rc, prod) and redirect the requests that client is sending to the deployed version of my service to my local server instead.
I've attempted this with tools such as requestly. However this just results in a 307 response and the following error:
XMLHttpRequest cannot load http://localhost:59517/api/users. Response for preflight is invalid (redirect)
While we are verifying the correct behavior on the server via TDD unit tests. There are occasions where it would be nice to be able to use an already deployed client to test a local server to get a better feel for what might break in the integration tests during the automated build. Are there standard ways of doing this sort of microservice testing that does not involve local buildin/configuring of the web client?

Web socket in a Windows Service

I created a windows service that is hosting WCF web service on port 3000 and web socket on port 8800. The site using these services is also hosted on the port 3000. The communication between the site and the WCF web services works very fine and I'm able to call them.
However, the site is developped with angular2 and I'm using "socket.io-client" to connect to the web socket (implemented using websocket-sharp) and when I do this, I get:
GET
http://dev-sp-build.sfpd.fgov.be:8800/socket.io/?EIO=3&transport=polling&t=LeEF_1J
501 (Not Implemented)
Suivi de
XMLHttpRequest cannot load
http://dev-sp-build.sfpd.fgov.be:8800/socket.io/?EIO=3&transport=polling&t=LeEG3vq. No 'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://dev-sp-build.sfpd.fgov.be:3000' is therefore
not allowed access. The response had HTTP status code 501.
The second error seems to indicate an issue with CORS. However, I have no idea how to define the correct header as the web socket is hosted in a Windows Service.
The first error is also quite weird, I don't get why I get a "501 Not implemented". It looks like a .NET error in a virtual method that should be overriden but I checked the documentation of "websocket-sharp" and didn't find anything about that...

Build a WCF according to a reference service

I am building a WCF service based on a given wsdl reference service given by Readify as a part of its technical interview process. What I did is that I built a client application that explores the methods exposed through this WCF, and then I started implementing my own version from this WCF.
I have finished the coding and the hosting part for my WCF version, and I had built another client that tests the results return from both WCFs, and everything seems okay. However, when I pass my WCF URL to the Readify testing app, it gives me this message:
I couldn't connect to that service with the contract I expected. The exception message was: There was no endpoint listening at {My WCF URL} that could accept the message.
Although, I am sure that the methods names and parameter types and the returned are the same.
Any hint???

HTTP to HTTPS silverlight wcf cross domain issue

I've been looking all over the site and on stack overflow and I just can solve my issue.
Network Setup
The way my network on my staging world is that I have clients looking at my web app on a 443 port - https, but the underlying structure is listening on 80 port - http. So when my apps talk to each other its on port 80, but when the clients visit the site its port 443. So for example, my svc called from silverlight would be on port 80.
I should also point out that on my staging and test domains: I have a web server acting as a portal to my app server; but this shouldn't really matter since I was able to get this working on test. It's just that staging has the HTTP forwarding to HTTPS.
Application
I have a silverlight xap file that is on the same domain as my hosted web application using IIS 6.
Now since my silverlight xap file and my web application are on the same domain, I have no problems running this on dev and test, but when I try to deploy to staging I'm getting a weird cross domain reference problem:
"System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI . 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."
Digging around, I realize that my app thinks that my xap (or the service I'm calling) and my web app are on a different domain, and looks for the crossdomain.xml and clientaccesspolicy.xml files automatically, I can't really stop it. However, in my application, this is not the case. They both reside on the same domain. I have used fiddler and I didn't see anything about another domain or even a subdomain for that matter.
Browser Issues
Another weird thing that I found out is an issue with chrome vs ie:
On chrome it finds the crossdomain.xml and clientaccesspolicy.xml telling me its insecure, then it does another fetch from the https side, signalling a 404 error. However, on IE I'm getting a 302 redirect. On microsoft's doc about clientaccesspolicy.xml you aren't supposed to do any redirects from the xml file; this is mentioned here: http://msdn.microsoft.com/en-us/library/cc838250(v=vs.95).aspx
So my question is, if my app and xap are on the same domain, why are those xmls trying to get fetched? Is it because I'm using a DNS instead of an IP address? I also stumbled upon this site: http://msdn.microsoft.com/en-us/library/ff921170(v=pandp.20).aspx
It states: To avoid cross-domain call issues, the remote modules' XAP files should be located on the same domain as the main application; when deployed like this, the Ref property on the ModuleCatalog should be a Uniform Resource Identifier (URI) relative to the main XAP file location on the Web server.
What does that even mean??
EDIT
Okay so I changed the services to point to https instead of http. However new error comes out: The provided URI scheme 'https' is invalid; expected http.
The good thing is, it doesn't even check crossdomain.xml or clientaccesspolicy.xml; so it now realizes it's on the same domain. But now it's expecting a service on port 80, but the name has to follow as https:// in order for it to work.
I think the only solution I have now is to break it off as being a virtual directory, make it a root node of its own website, and make the whole thing as 443. Save myself the headache.
It sounds like you're working in an environment where there is a load balancer offloading the SSL traffic. In this situation, your client(Silverlight) needs to be configured for HTTPS and your server must be configured for HTTP. This is because a device between the two parties is decrypting the SSL data.
In situations like this, aside from the normal client and server side configurations, your server side code needs to be a bit more forgiving about the address of the request.
You likely also need to add an attribute to your service implementation to allow your client to call over HTTPS, but have your service listening on HTTP.
Add this to your service:
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
This allows your client to call https://my.domain.com/service.svc and have your server live at http://my.domain.com/service.svc.
Here are some links that might help as well:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/b5ae495b-f5fb-4eed-ae21-2b2280d4fec3/address-filter-mismatch-wcf-addressing
http://www.i-m-code.com/blog/blog/2011/11/30/hosting-silverlight-over-http-under-f5-big-ip/
http://www.i-m-code.com/blog/blog/2011/08/18/hosting-silverlight-under-https/

How to see SOAP data my client application sends?

I have a project where I have created web service proxy classes with wsdl.exe and then simply create an instance of that class (inherits System.Web.Services.Protocols.SoapHttpClientProtocol) and call the method that should send a SOAP message. I'm using Visual Studio 2008 if that matters. And I'm trying this in my development machine without access to actual web service that is located inside of customer's intranet. So, the sending will of course not succeed and I will not get any response back but all I would like to see is the exact content of SOAP messages this solution creates and tries to send. How do I see that?
Use fiddler.
Have a look at SOAPUI from eviware.com.
Its a free for personal use Java app. Among other things you can
set it up to run as a dummy test server. Just load up hte WSDL
and enter the dummy data.
In test server mode it will log your requests so you can see whats happening
inside the request message.
If you're Web service is accessed by clear text, non-SSL HTTP, you can just use a sniffer, like Wireshark, to see the data coming from and to your application. Wireshark can trace, filter and analyze wire data. I have used it do debug HTTP and other protocols many times, and it's a great tool to do this.
SOAP messages are simply XML data sent using the HTTP POST method. So you can for example install a local web server on your development machine, configure your web service to use some dummy URI on this server, and grab the network traffic with WireShark (AKA ethereal). The big advantage of this method is that it involves no coding.
Alternatively you can use an HTTP echo server that dumps its incoming traffic, like this one (found while googling "http echo server"):
You can intercept the call with tcpMon

Categories