I have the following code for consuming a service that is not working for me. Can anyone suggest what I can do to narrow down whats going wrong? I know this is vague so please tell me what you require to provide any suggestions.
The address is: http://localhost:57667/ExampleService.svc/
When visiting directly I get the 'You have created a service... message'
The code that goes wrong is here. It causes the following error:
_url = "http://localhost:57667/ExampleService.svc";
TextReader textReader = new StringReader(HttpPostClient.Post(new Uri(_url), bodyData.ToString(), _exampleServiceRequestEncoding, Properties.Settings.Default.HttpPostClientExampleAvailabilityTimeout));
ERROR MESSAGE:
When visiting this URL directly: http://localhost:57667/ExampleService.svc/ProcessRequest
The exception message is 'No component for key example.ExternalWebServiceStubs.Example.ExampleService was found'.
Castle.MicroKernel.DefaultKernel.get_Item(String key) at Castle.Facilities.WcfIntegration.WindsorInstanceProvider.GetInstance
many thanks,
The normal practice would be to create a proxy class via svcutil.exe (visual studio command prompt) or "add service reference" to consume the service, and then for you to use the methods of your proxy class to call your service's methods.
This tutorial should help (it's based on Visual Studio 2005, you didn't say what version you were using, but you should get a good grounding)
http://msdn.microsoft.com/en-us/library/bb332338.aspx#msdnwcfhc_topic6
Since troubleshooting wcf services will be lot more easier when you provide web.config element also at service side.
My general guess here is, all the wcf services by default uses wsHttpBinding which will not allow direct calling of service like an asmx service we do.
You can replace wsHttpBinding with basicHttpBinding and disable the security to your service in order to get the service work like you are expecting.
Please add some more details about ExampleService.svc binding and it will help you get this resolved fast
Hope this will help
Related
I know there are thousands of step-by-step samples for consuming a SOAP project with C#.
Actually, I tried many of those but didn't really get to understand how it works, how were needed components built or how to integrate a certificate for a secure connection.
I would be really grateful if any of you guys have a magical resource, since I read somewhere I shouldn't do it this way or another, I really want to know this well.
Thank you,
Best regards.
It's really simple actually. Suppose you have a service at http://myhost.com/XService.svc - right click References in the solution explorer and choose "Add a service reference" (older versions of VS called it web reference/web service)
A wizard appears; pop your URL into it, set a few options and hit Go
You'll get a client class set created that references the service, with methods that take a set of typed parameters based on what the service said it wanted when VS queried its WSDL. You might use it like:
var c = new XServiceClient();
bool result = c.CreateNewPerson("John Smith", 30, "js#hotmail.com");
The service client handles all of the xml creation, tcp socket connection, data transmission etc necessary to pass those 3 values you sent, to the web service so that the relevant method is called, the response is returned etc
I have my service on a web site. I try to run this example, first just the server part:
:What steps do I need to take to use WCF Callbacks?
But I get this message: "Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it."
The Web.config file, doesn't have definitions such 'BasicHttpBinding'. It only has more general defitions. Do i have to add lines to it, or there is a more simple way. Many thanks.
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 am trying to create very simple client application for our Polish auction service called Allegro. They provide API in SOAP architecture. The problem is that, every time I try to call any of the methods, I receive:
Error in deserializing body of reply message for operation 'name of method'
I am new to web services in general so I have no idea how to find the source of the problem. I am absolutely sure that I am passing correct arguments to the method in the example below:
class Program
{
static void Main(string[] args)
{
string ALLEGRO_KEY = "******";
AllegroWebAPI.AllegroWebApiPortTypeClient allegro = new AllegroWebApiPortTypeClient();
long version = 0;
String versionStr = allegro.doQuerySysStatus(out version, 1, 1, ALLEGRO_KEY);
}
}
I am using .NET 4.0 in Visual Studio 2010. I know that there are many people using this API with .NET, even Allegro itself has official Windows Phone 7 client that uses this API. How can I troubleshoot that?
Here is the WSDL address:
https://webapi.allegro.pl/uploader.php?wsdl
I have had similiar problem. See your inner exception. I resolved it by extending the size of readerQuotas in web.config :)
It sounds like there is something in the response message from the Web Service which WCF is having difficulty understanding.
Configure WCF Tracing with both service and message tracing enabled. This should give you the actual response message from the web service and will also give you more detailed error messages.
Similar issue here. Needed to update service reference after one of its dependencies was changed.
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";