I have code that calls a web service. We'll say a "3rd party" web service. So I can get the wsdl for this service, in fact I've generated a proxy class using this wsdl.
The requirement that I'm trying to meet is this: Create a web service that LOOKS just like the above mentioned one, but does other stuff. So the web service URL will be changed in a config file/database, to allow switching between the two web services.
What I'm not sure about is how I can use that proxy class that I generated, or some other method, so that the namespacing and data contract look exactly the same. I don't know much about this and these are terms that colleagues have tossed out there. I only need to actually implement one of the web service's methods in my version.
Build site with any technology you know of and return responses that match that service.
Note that if you just need to return static enough responses for occasional testing you can use Fiddler as it allows to return arbitrary responses instead of real once.
Related
I have built and deployed a web service onto a server – let’s call this WebService1. The web service has a number of utility methods which can retrieve, update, remove entries from a database.
I want to create another web service with different but similar functionality to WebService1. Let’s call this WebService2. It will also have the ability to retrieve, update, remove entries from a database, but the code inside the methods of WebService2 will be fundamentally different to WebService1, and WebService2 will be accessing a separate database to the database of WebService1.
If I set up a Service Reference using the endpoint address of WebService1 inside a C# Project, in theory should it be possible to only change the endpoint address to instead point to WebService2 without needing to update the Service Reference and still be able to call methods from the Web Service?
Obviously if I build and deploy WebService1 onto two different servers, it’s very simple to just change the endpoint address between the two services since they are using the exact same codebase, but should it be possible to do something similar by deploying WebService1 and WebService2 to two different servers if the two services have different code bases, provided the public facing web methods have the same method names with the same argument types and names and same return types? If this is possible, is there a fundamental difference between the two web services that would need the service reference to be updated as well as changing the endpoint address when changing between the two?
i guess you are using soap web services. soap technology uses XML serialization in order to send and receive and XML serialization depends on lots of thing like: class namespace, parameters type, ....
for instance if you are using different namespaces in the inputs you wouldn't be able to switch the address.
but i thinkyou are doing it wrong. if you use restful web services with json input you can easily switch between endpoints.
restful web services is more flexible than soap.
We currently have one big C# ServiceStack API project for all the services within our system. I want to split this up into smaller API's that all run separately, for ease of deployment and testing. Pretty similar to what's described here by Mike Hadlow.
However, instead of using Nginx I'd like to use ServiceStack as the reverse proxy. This "external" API would handle authentication concerns and then forward any incoming request to the relevant internal API, using an async HTTP REST call.
How would I create this service forwarder, though? Let's say I have an internal API that accepts a /hello call. If I try to create a custom ServiceRunner on the external API host I cannot just intercept ANY call. It still expects certain routes to be present, so calling /hello on the external API fails. Do I need to create dummy /hello route on the external API host in order to be able to intercept them with my own ServiceRunner? Looking at the rest of ServiceStack I'm sure there's a cleaner way.
Bonus points if it can still be combined with Swagger :)
At the time this question was originally asked, there was no simple way of creating a wildcard route off the the root of the service base url. I.e. if the service was hosted at the root, there was no simple way to create a /{*} wildcard route, same if the service was hosted at another point, say /api, there was no simple way to create a /api/{*} wildcard route.
However, support for a Fallback route has recently been added to ServiceStack (see detailed example implementation.) Using a Fallback route, you can proxy all unrecognized requests to the back-end without having to enumerate them in your ServiceStack project. Doesn't provide Swagger support, however.
You can easily convert ServiceStack into a Reverse Proxy with the new Proxy Feature added in v4.5.10.
I'm working on .NET, I want to write an interface on web service for my clients(multi client) so they can inherit from my interface to make their own web service, and I can call their web service dynamically.
Is there any way to make it?
Thanks.
Edit:
Because I'm new on web service. I will make it more clear.
I want all my customer's web sevice have same method.
I have several cuatomers. I want to have some object or interface from my web site so they can inherit from it.
I can store their web service's URL to database, and I can call their service dynamically.
So, how to do it?
It is very simple, you don't need to do anything in terms of inheritance really, that's the basic premise of web services.
Just create a dummy web service of your own (You can use this one for testing as well to return test values) and give URL to your customers.
They can all get the specs (basically they just need to add "?WSDL" at the end of your test web service) and get WSDL which they should implement into their own web service.
If that test web service is internal to your network you can simply get WSDL yourself and email it to them.
Once they all implement this web service, you can just connect to theirs and it will behave exactly the same.
Please forgive me for this basic and a little theoretical question as I dont know much about web services.
I m not refering WCF service, I am reffering simple service in .net / C#. I want to know how to know is it soap or rest service ?
How we can change this type from Soap to Rest and vice versa ?
Thanks
XML Web Services (aka classic/legacy ASMX web services) should not be used for active development. If you must, there is a nice walkthrough on MSDN for adding Web references in more recent versions of Visual Studio (> 2005).
On the other hand, if your web service is truly Restful then you won't be able to create the equivalent of a service reference to it. You'll need to either use the HttpWebRequest, WebClient, or the new HttpClient from .NET 4.5 (also available from the Rest starter kit which is depreciated as well).
As an alternative if you are looking to implement a client that is able to handle both situations, I would recommend HttpWebRequest to POST to the SOAP (non-WCF) service. The problem with this method is you'll likely have to wrap the request in the SOAP wrapper yourself. Luckily there are examples of doing so on the net that you can at least use as a starting point.
ASMX services are build upon SOAP. REST is simply a HTTP based, You can access(or call) your business resources the way you access the normal URLs.
For ex in products catalog system, by using asmx you create set of functions to add,update,delete products. like addProduct(),updateProduct, etc..
But in REST, you will be having single point of access, like http:\mysystem\prodcuts. To retrieve,add,update,delete products, you will be using respective HTTP verbs (GET,POST,PUT,DELETE) on the same URL.
so,technically it's not possible to convert asmx(SOAP) service to rest...
Before I venture down the path of creating one, I was wondering if anyone knows of a utility program which will take the REST Help page of a WCF Rest Service and create the relevant Client for C# consumption.
Similar to what svcutil.exe does for WCF Services or what wsdl.exe did for web services but for WCF REST Services
Kind Regards,
Andrew
EDIT Some more detail:
Please see this link: http://msdn.microsoft.com/en-us/library/dd203052.aspx
In the restful service using the WCF Rest Starter Kit Preview 2, they supply types which will be serialized. But My intention is be able to create clients form the help page which describes schemas. Clients could then be created for C#, JavaScript, ActionScript etc.. shearly as a strongly typed version of the restful service, not a requirement or necessity. It is a program or uitlity I am wondering exists which does this
I think you might be looking for the WebChannelFactory. It can generate a channel class based on a WCF-attributed REST interface.
Well, there will not be any use even if you would like to abstract. ALL Rest services can use HTTP verbs like GET, POST, PUT, DELETE
So, basically what your client can have is only a static class which can accept the end point, network credentials, a name value collection which needs to be passed and the verb to use.
This would be more of a utility class rather than a client.
I don't remember seeing WSDL or some contract based on which we can write clients for the REST services.
I hope you don't spend too much time basing your code on the current help page of a pre-release piece of code. Are you even sure this help page provides all the information you would need to produce clients?
Also, have you seen Prerelease 2 of the WCF REST Starter kit yet? If no, go look. There's new client-side technology in there.
Why would you create clients for a RESTful service? You don't need one - you just need to be able to initial HTTP requests. If you would like to call the same operations via SOAP or some other method then create a new endpoint for the service and a new contract and expose mex for it so that svcutil can consume it.