Web Service Request issue in C#.net WSDL - c#

We are creating a web service request for IBM Maximo web services in C#.net , the issue is apart from for few web service requests we get succesful response for all other web services, but for some requests there is no response at all, but when we give request for the same using the SOAP UI, we get response.
Where would the problem be ? Any ideas?.
Many thanks ,
byfour

Any ideas?
Start debugging. First of all, of course your application contains logging, so you can see whether any exceptions occur while sending the message.
If no exceptions occor on your end, you can configure tracing to log all actions the WCF plumbing is executing, so you can see whether that part goes well. If it does, you can start debugging the network. If you see your message going over the wire, it's time to pick up the phone and call the other party and ask if they see anything happening after they receive your messages.

Related

Show message when WCF service is down

I have searched about, how to know if WCF service is down OR not and I came to know that the only way to know this is to call WCF service method. We can create a method that just return true.
In my case I want to show a message when service is down to the client and for other exceptions of WCF service, I want to show the exceptions as it is. What should be the best way to this ?
If the service is yours then go ahead and use that method that returns true.
However, you should just go ahead and consume the service, as it's not necessarily true that it will remain up the entire time that you consume it. Handle your interim timeouts and errors gracefully for all of your operations and show your messages accordingly.
One client-side thing you can do is send a WebRequest and see if it returns a HttpStatusCode.OK but it can't promise you that the service won't fail or is running.
During your consuming the service you can expect FaultException, proxy and channel state errors, invalid configuration (bindings, etc) and CommunicationException objects.
You can read more on this on MSDN.
From there:
Communication errors occur when a network is unavailable, a client uses an incorrect address, or the service host is not listening for incoming messages. Errors of this type are returned to the client as CommunicationException or CommunicationException-derived classes. Application errors occur during the execution of a service operation. Errors of this kind are sent to the client as FaultException or FaultException.
This problem can be solved only "client side", because server can reply with "true" only if WCF service is running and well configured.
All the other case should be managed from client.
In a simple way you can call that simple service if it reply it seems all OK, otherwise you'll get a faultexception or an exception that you need to catch.
Pay attention at async / await, you need to catch exception in the closer place to the web call otherwise you'll get an uncaught application exception that will crash app domain.

See Raw Response to a WCF Call

I'm building out a simple C# application that integrates with a SOAP web service. I add the service reference to the appropriate WSDL and everything works out fine so far.
Occasionally, the server's firewall will respond with a 503 error before the request gets a chance to hit the web service. That 503 error also contains some HTML with an ID number (which changes each time) that I want to capture.
If I catch the exception, it doesn't give me the full message - just the re-formatted basic exception that says the server is too busy.
I tried the message inspectors suggestion from this post:
Intercept SOAP messages from and to a web service at the client
...and it gives me the outbound request, but it never hits the AfterReceiveReply call, so the response isn't captured.
I've also tried subscribing to all of the channel's major events (Faulted, Opening, Opened, UnknownMessageReceived, etc), and I've tried inspecting the channel when I catch the exception, but nothing seems to work.
Any thoughts or suggestions?
Why not just run fiddler on the machine your soap client is running on and intercept and inspect the traffic that way?
Turn on WCF Tracing. In particular, Message Logging.
It seems like disabling SOAPProcessing in the .config file may be a step in this direction, but I was unable to figure out how to enable this setting via code (and I cannot use a .config file in my final application because this is a plugin and the parent app's .config file is dynamically generated each launch).
I was able to work around this somewhat. In my situation, I had separate dev and production servers. The 503s errors were happening mostly on the production server (likely due to the firewall being sensitive about a different hostname in the API requests), so I ended up with a solution that duplicated the API requests and sent them over to the production server.
(This was okay, because the production server was not configured with anything that would be affected by any API requests that made it through the firewall. The requests would just be considered invalid.)
I did this by using message inspectors to generate the last outgoing request. Then for each outgoing request, I generated a new WebBrowser control, set the proper headers (SOAPAction and all that), re-injected the security credentials (the message inspector stripped them out at runtime), and then posted the request to the production server with that WebBrowser control. The WebBrowser instance's DocumentCompleted event let me dump the result and search for the ticket ID when appropriate.
Not exactly glamorous, but it works well.

php soap client and c# soap server

I am currently working on a project which I think using soap as part of it would be a good idea but I can't find how it will work in the way that I need.
I have a C# Console Application called ConsoleApp, ConsoleApp will also have a PHP web interface. What I'm thinking of doing, is the PHP web interface controls the ConsoleApp in some way, so I click a button on the web interface, then this does a sends a soap request to a soap service and then the soap service, sends the information on to the consoleApp, and the result is returned back to the SoapService and then returned back to PHP.
This seems like it would need to separate soap services, one for php to interface with and one within the ConsoleApp but this doesn't sound right, I think I might be misunderstanding the purpose of Soap.
How can this be achieved. Thanks for any help you can provide
UPDATE
As requested I thought I'd add a bit more information on what I am trying to achieve.
In the console app, it is acting as an email server sending out emails that are given to the program and then being sent on, and if it can't send it retries a couple of times until the email goes into a failed state.
The web interface will provide a status of what the email server is doing, i.e. how many emails are incoming, how many are yet to be processed, how many have sent and how many have failed.
From the web page you will be able to shutdown or restart the email server or put one of the failed emails back into the the queue to be processed.
The idea is, when the user adds a failed email back into the queue it sends a soap message that the console app will receive, add the information back into the queue, log the event in the console apps log file, increment a counter which is how it keep track of emails that need to be processed. Once this has been done it should then send a response back to the web interface to say whether or not the email was successfully added back into the queue or whether it failed for some reason.
I don't really want to keep on polling the database every so many seconds as there could be the potential for their to be a large number of emails that will be being processed so polling the database would put a large load on the MySQL server which I don't want, which is why I thought soap as the email server would only need to do something when it receives a soap request to do something.
Thanks for any help.
Every web service is going to need a client (in your case PHP) and a server (ConsoleApp). Even though there are two endpoints, it is still one web service. Your PHP will send a SOAP request which ConsoleApp will receive, process and respond to with a SOAP response.
So when someone clicks the button on the web page, you can use JavaScript to build and send the SOAP envelope in the browser. The alternative is to POST the values to a PHP page that will build and send the SOAP.
I have to admit though, your scenario sounds a unusual. I personally haven't heard of web pages talking directly with console apps. Web pages usually talk to web servers, and the servers are usually the ones issuing atypical requests, like your request to ConsoleApp. While it is technically possible, but I think it is going to be harder then you are expecting.
Personally, I would ditch SOAP in favor of a much more simple and scalable solution. Assuming you have access to a database, I would have the PHP create a record in the database when the user clicks the button. ConsoleApp would then poll the database every X seconds to look for new records. When it finds a new record, it processes it.
This has the benefit of being simple (database access is almost always easier than SOAP) and scalable (you could easily run an arbitrary number of ConsoleApps to process all of the incoming requests if you are expecting heavy loads). Also, neither the PHP page nor the ConsoleApp have a direct dependency on the other so each individual component is less likely to cause a failure in the whole system.

How to Debug a web service

We have a Win32 application that connects to a third party application to send some info to it. That application has a web service that we call its methods. One of its web methods is called GetDevices and when our application is calling it, it will fail to work and I have no idea what are the details of this failure. So we should write a small diagnosis application that can create some detailed log files to know what is going, send it to them to run it and then we may know what is going on with more detail. Now do you have any ideas what is a good way to write such a diagnosis application for this debugging purpose?
If this web service is using HTTP (either SOAP or REST) you can use Fiddler to snoop the HTTP traffic and see what's happening.
When web requests are made, the request (and response from the server) will show up in Fiddler, and you can use that to determine why it's not doing what you expect.

Application hanging in a web service

I have an application that users were complaining that it hangs when the user trys to perform a certain action. I found it that it is hanging in a web service call. The web service is running on a remote server. I can't figure out how to debug into the web service through VS when the code is on a remote server.
How do I find out in the web service where exactly the code is hanging?
If you don't have access to the source of the web service then you're not going to be able to "debug" it. If you want to try to externally debug it then you can create a page that sends various inputs to it (some that should work, some that should error out, etc). You can then access this page in a browser that has developer tools (I would recommend Firefox w/ Firebug or Google Chrome) and then look at how long the calls are taking. Google Chrome will show you how long it took to send the request, how long it waited, how long it took to receive, etc. If it IS the actually web service and you don't have access to it then it would be odd that you were responsible for fixing this issue. I have a feeling though, if this is a robust web service, you're going to find that you're either having a networking issue or your sending it some invalid input or something along those lines.
If you do have access to the source code then simply run the web service locally and point your local version of the application at the local version of the web service. Any breakpoints you put in the web service will hang the application and you will be able to step through it just like you can non-web-service code.
In your own code, take a look at what is going on with the web service call. e.g Does it throw a fault? Timeout? Does it ever return a successful response? If not, are you sending valid data?
If the web service call is successful but just slow, consider how you might make your application appear to be more responsive. One possibility is to use Asynchronous Programming.

Categories