I am trying to test the availablity of WCF service as a part of a tool.
Is it possible or do I have to call a method inside that WCF to really test that?
I have tried client.downloadurl(wcfurl) but it is failing.
Any Ideas?
To test the existence of a WCF service all you need to do is enter the url of the service into a browser:
http://www.yourdomain.com/yourservice.svc
You should be able to make the same http request in code and check the response. If it's OK then the service exists.
This doesn't check the methods on the service though.
Create a HTTP request using the URL of your service. Don't forget to set the timeout. The response code 200 means it is all OK
I would try this tool from microsoft.
They provide you this, simply launch the tool and you will see the available methods as exposed on your IService.
http://msdn.microsoft.com/en-us/library/bb552364.aspx
You can provide the IService code for feedback.
Related
I need to enable my webAPI REST service to accept a request in the format of:
www.someURL.com/OldService.svc
I am working on an existing application that used to use WCF. These methods do not have to return anything but a 200 response. We need the REST service to handle this call so we can retire the old WCF service, but systems will fail if we don't support this WCF request.
Has anybody done this before?
edit:
Is it possible to do this with just adding a new route?
You can add a WCF service (.svc) to a Web API project by simply adding a New Item and selecting Web, it will then show up in the list as WCF Service.
Maybe you could use the Route attribute(using System.Web.Http) for the old service? I've used this for route names like [Route("SomeRoute")] but I'm not 100% sure if the .svc extension will interfere with anything.
[Route("OldService.svc")]
[HttpPost]
public HttpResponseMessage NewData(Data SomeData)
{}
My client hosts a few web services and has ASP.NET Web pages that will demo the web service and acts as a quick check to verify that the web service is up by the client. The problem is that the WSDL might be missing or invalid, but the Web Service will still work.
What I'd like to add to the ASP.NET web service client is a way to verify that the WSDL is there and valid, but have no idea where to start. Any suggestions would be greatly appreciated! Code behind is C#
I'm not entiery sure what you mean with verify that the WSDL is valid. Only thing I can suggest is, use an HttpWebRequest on the specific URI and see what response you get then either throw an exception based on specific status codes like 404 for example or handle it in a different way.
You can fetch the status code value
var request = (HttpWebRequest) WebRequest.Create("http://example.com/service.wsdl");
using (var r = (HttpWebResponse) request.GetResponse())
{
var result = r.StatusCode.ToString() == 200.ToString() ? "Success" : "Service not found";
Debug.WriteLine(result);
}
Hope this helps, goodluck.
Edit: if you know what services you're going to be testing you can simply add them as service reference in your client project and try to do an RPC on the service methods to see if it's available. Pictures below show to add a service reference.
Your scenario doesn't completely make sense. You could make a request to the service WSDL endpoint, http://something/service.asmx?wsdl and you could confirm that what comes back is a WSDL file. You could even validate it against the WSDL and XSD schemas.
This wouldn't tell you whether it was a WSDL that represented the service. It could conceivably be a WSDL for some totally different service.
Maybe more importantly, have you had problems where the service was available but the WSDL was not? In that case, rather than create diagnostics, I recommend that you fix the problem.
I'm trying to use a webservice with the endpoint https://services.example.com/ASP_SecureWebServices.cfc?wsdl.
In the documentation I have this:
Request
<authorise>
<site>xxx</site>
<login>xxx</login>
<password>xxx</password>
<partnerid>xxx</partnerid>
<wstype>xpt_exhibitors</wstype>
</authorise>
Authenticated Response
<authorisation>
<service>getAuthToken</service>
<authorised>OK</authorised>
<authtoken>255461</authtoken>
</authorisation>
I’ve never used ColdFusion before, so I don’t understand how to make the request. Can anyone assist?
I’ve added a service reference like this:
But I don’t get this method:
You're actually hitting the CFC directly, but you add ?wsdl on the end to actually have it return the WSDL.
Also, all of your methods in that CFC that you want accessible will need access="remote".
So your actual endpoint would be closer to this:
https://services.example.com/ASP_SecureWebServices.cfc?wsdl
Going to go out on a limb, but my guess from the documentation is that the method you need to access is called authorise. With that in mind, you would call the web service as follows:
https://services.example.com/ASP_SecureWebServices.cfc?method=authorise&site=xxx&login=xxx&password=xxx&partnerid=xxx&wstype=xpt_exhibitors
By default, ColdFusion will return a WDDX packet; if you want JSON instead, add &returnformat=json.
Check the WSDL to find out the methods exposed in the web service.
Okay, simple situation: I'm writing a simple console application which connects to a SOAP web service. I've imported a SOAP Service reference and as a result, my application has a default endpoint build into it's app.config file.
The web service, however, can run on multiple servers and the URL to the proper web service is passed through the commandline parameters of my application. I can read the URL, but how do I connect the web service to this custom URL?
(It should be very simple, in my opinion. It's something I'm overlooking.)
Is this using an auto-generated class deriving from SoapHttpClientProtocol? If so, just set the Url property when you create an instance of the class.
Well, .NET can provide some very useless error messages sometimes. In IIS, the service was configured to AutoDetect cookieless mode. As a result, I had to append "?AspxAutoDetectCookieSupport=1" to the URL. Although that would fix the problem, it was just easier to go to the IIS console, open the properties of the service, go to the ASP.NET tab page, click the "Edit configuration" button, to to "State Management" in the newly popped up screen and change "Cookieless mode" into something other than "AutoDetect"...
Excuse me. Dumb error. Am going to hit myself on the head a few times for this. ;-)
As Jon said, you set the Url, as in:
Namespace.ClassName nwe = new Namespace.ClassName();
nwe.Url = "http://localhost/MyURL/site.asmx";
I've got a siluation where i need to access a SOAP web service with WSE 2.0 security. I've got all the generated c# proxies (which are derived from Microsoft.Web.Services2.WebServicesClientProtocol), i'm applying the certificate but when i call a method i get an error:
System.Net.WebException : The request failed with HTTP status 405: Method Not Allowed.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
I've done some googling and it appears that this is a server configuration issue.
However this web service is used many clients without any problem (the web service is provided by a Telecom New Zealand, so it's bound to be configured correctly. I believe it's written in Java)
Can anyone shed some light on this issue?
Ok, found what the problem was. I was trying to call a .wsdl url instead of .asmx url.
Doh!
I found this was due to WCF not being installed on IIS. The main thing is that the .svc extension has to be mapped in IIS See MSDN here. Use the ServiceModelReg tool to complete the installation. You'll always want to verify that WCF is installed and .svc is mapped in IIS anytime you get a new machine or reinstall IIS.
I had the same problem, but the details were different:
The Url we were using didn't have the file (.asmx) part. Calling the Url in a browser was OK. It also worked in a simple client setting the URL through Visual Studio.
But it didn't worked setting the Url dynamically! It gave the same 405 error.
Finally we found that adding the file part to the Web Service Url solved the problem.
Maybe a .Net framework bug?
You needto enable HTTP Activation
Go to Control Panel > Windows Features > .NET Framework 4.5 Advanced Services > WCF Services > HTTP Activation
hmm are those other clients also using C#/.NET?
Method not allowed --> could this be a REST service, instead of a SOAP web service?
MethodNotAllowedEquivalent to HTTP status 405. MethodNotAllowed indicates that the request method (POST or GET) is not allowed on the requested resource.
The problem is in your enpoint uri is not full or correct addres to wcf - .scv
Check your proxy.enpoint or wcf client.enpoint uri is correct.
In my case the problem was that the app config was incorrectly formed/called:
in config the service url was using "localhost" as domain name, but real hostname differed from the URL I called :( so I changed the "localhost" in config to domainname thah I use in URL. That`s all!