How to solve error in windows phone 8 application when retrieving app from background with web services? - web-services

I am developing application and facing a problem when I use web services.
At any page which request web service, if app goes to background (by search or menu press for example) before request complete it causes an error when I retrieve the application from background again:
An error (Exception of type 'System.Net.WebException' was thrown.) occurred while transmitting data over the HTTP channel.
Any solution for this problem ?

When your application is sent to background, it is suspended, and all connections are therefore cut off. There's nothing you can do about that. Just catch the error and retry the call to the webservice.

You need to call the webservice again when the application is reactivated. One way of doing it is to maintain a bool variable flag.
set it to true when the webservice is started.
set it back to false when the response is received
in the Application_Activated event handler(App.xaml.cs) check the status of flag and call the webservice again if the flag is true.
Otherwise if you just wish to keep your webservice running under lock screen then set
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

If your app goes to background your webrequest wont complete, You cant do anything about that. But you can prevent crash.
When you know the app is going background ( may be in onNavigatedFrom()) you detach the handler you previously attached to xxCompleted event or handle the thrown exception in handler for xxCompleted in the same way. The first solution implies you service client object must be a class member (private maybe), otherwise it wont be in scope in onNavigatedFrom(). To complete the request later you may use a marker ( bool successful, required) and in OnNavigatedTo() you can do like:
if(required && !successful)
{
// make the request again
}
still exception will be caught in the generated reference file, but the app wont crash and you'd know when you need to make the webrequest again.
I found the same problem, when I tried to fetch a sas uri and calling the PhotoChooserTask.show() simultaniously. So I had to ensure that webrequest is complete before the calling PhotoChooserTask.show().

Related

System.ServiceModel.FaultException: Server was unable to process request. ---> ... with key 0 was not found

I have a simple service (C# web service) that accepts an integer and returns an integer, i have tested it using Storm it is working properly.
Now i am calling this service in a for loop in a file with around 2000 records approx, this service is failing giving the above error with some records. If i run the error file it goes through as if nothing was wrong, what might be the problem please help.
The error doesn't seem related to it being a web service call: it seems to indicate you either tried to GetEntity and passed in a zero/NullIdentifier() (not a valid Id), or maybe you tried an CreateEntity and that entity has a foreign key that is not filled in (i.e. zero/NullIdentifier() again).
I would start by checking the logic inside the WS method for those action calls and the inputs you are using there.

Enterprise service object from WSDL returns null

I created a service consumer through the wizard, based on a WSDL. Proxy object is generated, all structures and methods are found. Then, I add a logical port through SOAMANAGER - all fine, it pings and the connection works.
I populate the input structure, call my method and get an error: Error during proxy processing (PART UNKNOWN (NULL)). This is a very useless error message to me.
So, I activate all manners of tracing, so I can see what's going on calling and retrieving data. I can see that
My proxy is called correctly
The payload sent TO the service looks correct
The payload received FROM the service is correct. I know this because it's identical to the XML I get back calling the service through other means.
The transformation is empty
Here a screen of (the start of) the returned XML. getRecordsResult set is what I need:
This is the second response, after "conversion":
Nothing about this service has been customized: it's generated straight up through the wizard. I have already deleted and recreated it but no results.
Anyone got any advice on what to do next?

Automate Suspended orchestrations to be resumed automatically

We have a BizTalk application which sends XML files to external applications by using a web-service.
BizTalk calls the web-services method by passing XML file and destination application URL as parameters.
If the external applications are not able to receive the XML, or if there is no response received from the web-service back to BizTalk the message gets suspended in BizTalk.
Presently for this situation we manually go to BizTalk admin and resume each suspended message.
Our clients want this process to be automated all, they want an dashboard which shows list of message details and a button, on its click all the suspended messages have to be resumed.
If you are doing this within an orchestration and catching the connection error, just add a delay shape configured to 5 hours. Or set a retry interval to 300 minutes and multiple retries on the send port if that makes sense. You can do this using the rule engine as well.
Why not implement an asynchronous pattern?
You make it so, so that the orchestration sends the file out via a send shape while initializing a certain correlation set.
You then put a listen shape with at one end:
- the receive (following the initialized correlation set)
- a delay shape set to 5 hours.
When you receive the message, your orchestration can handle it gracefully.
When you don't, the delay shape will kick in and you handle accordingly.
Benefit to this solution in comparison to the solution of 40Alpha will be that your orchestration will only 'wake up' from a dehydrated state if the timeout kicks in OR when the response is received. In the example of 40Alpha, the orchestration would wake up a lot of times, consuming extra resources.
You may want to look a product like BizTalk 360. It has those sort of monitoring and command built into it. I'm not sure it works with BizTalk 2006R2 though, but you should be thinking about moving off that platform anyway as it is going out of Microsoft support.

Wso2 bps process hangs without reason

I have simple bpl process with 3 invokes in loop. One of instances hang without any visible reason. So process is in active state but it is not executing any longer. Last logged activity is call to invoke. I search database and find out that both request and response are present in table ode_message and they looks correctly. But output variable from invoke in table ode_xml_data is not filled. There is no logs in bps from time when message arrived. Is any way to find out what happen wrong?
I'm try to use Wso2 BPS 2.1.2

API Design: How should distinct classes of errors be handled from an asynchronous XMLHTTP call?

I have a legacy VB6 application that needs to make asynchronous calls to a web service. The web service provides a search method allows end-users to query a central database and view the results from within the application. I'm using the MSXML2.XMLHTTP to make the requests, and have written a SearchWebService class that encapsulates the web service call and code to handle the response asychronously.
Currently, the SearchWebService raises one of two events to the caller: SearchCompleted and SearchFailed. A SearchCompleted event is raised that contains the search results in a parameter to the event if the call completes successfully. A SearchFailed is raised when any type of failure is detected, which can be anything from an improperly-formatted URL (this is possible because the URL is user-configurable), to low-level network errors such as "Host not found", to HTTP errors such as internal server errors. It returns a error message string to the end-user (which is extracted from the web service response body, if present, or from the HTTP status code text if the response has no body, or translated from the network error code if a network error occurs).
Because of various security requirements, the calling application does not access the web service directly, but instead accesses it through a proxy web server running at the customer site, which in turn accesses the actual web service through via a VPN. However, the SearchWebService doesn't know that the calling application is accessing the web service through a proxy: it's just given a URL and told to make the request. The existence of the proxy is a application-level requirement.
The problem is that from an end-user perspective, it's important that the calling application be able to distinguish between low-level network errors versus HTTP errors from the web service, and to distinguish proxy errors from remote web server errors. For example, the application needs to know if a request failed because the proxy server is down, or because the remote web service that the proxy is accessing is down. An application-specific message needs to be presented to the end-user in each case, such as "Search web service proxy server appears to be down. The proxy server may need to be restarted" versus "The proxy is currently running but the remote web server appears to be unavailable. Please contact (name of person in charge of the remote web server)." I could handle this directly in the SearchWebService class, but it seems wrong to generate these application-specific error messages from such a generic class (and the class might be used in environments that don't require a proxy, where the error messages would no longer make sense).
This distinction is important for troubleshooting: a proxy server problem can usually be resolved by the customer, but a remote web server error has to handled by a third party.
I was thinking one way to handle this would be to have the SearchWebService class detect different types of errors and raise different events in each case. For example, instead of a single SearchFailed event, I could have a NetworkError event for low-level network errors (which would indicate a problem accessing the proxy server), a ConfigurationError event for invalid properties on the SearchWebService class (such as passing an improperly-formatted URL), and a ServiceError for errors that occur on the remote web server (implying that the proxy is working properly but the remote server returned an error).
Now that I think about it, there is also an additional error scenario: it could be possible that the proxy server is running properly, but the remote web server is down, or the proxy server has been misconfigured.
Is the approach of using multiple error events to classify different classes of error a reasonable solution to this problem? For the last scenario (the proxy is running but the remote server cannot be reached), I'm guessing I may have to set up the proxy to return a specific HTTP error code so that client can detect this situation (i.e. something more specific than a 500 response).
Originally I kept the single SearchFailed event and simply added an additional errorCode parameter to the event, but that got messy quickly, especially in cases where there wasn't a logical error code to use (such as if the VB6 raises a "real" error, i.e. if the XMLHTTP class isn't registered).
I think that some ideas I've used with Java exceptions may apply here.
Having a large number of different Exceptions gets pretty messy, yet we need to give enough detail to the user so we don't want to lose information.
Hence I have a small number of specific Exceptions, which I guess would correspond to your Events:
InvalidRequestEvent: Used when the user specifies bad information
TransientErrorEvent: used when there's infrastructure issues when a retry might work.
I tend to work in environments where we have clusters of servers so if a user request hits a dying server then if he resubmits he'll probably get a good one, hence from his perspective a simple retry often works. However sometimes the error is with a service such as the Network or Database and in which case the user needs diagnostic information to report to the helpdesk. Hence we need to decide on the extra information to put into the exception. This is (if I understand you correctly) your question.
In the case of InvalidRequestException we would bet giving some information about the problems with the input. It could be on the lines of "Mismatched parenthese" or "Unknown column CUTSOMER in table ORDER". In the case of TransientErrorException it could be "Proxy server is down".
Now depending upon your exact requirments you may not actually choose to put that text in the Exception, but rather an error number which the presentation layer converts to a locale-specific string (English, French ...).
So either Exception might contain something like this (sorry for that Java syntax, but I hope the idea is clear):
BaseException {
String ErrorText; // the error text itself
// OR if you want to allow for internationaliation
int ErrorCode; // my application specific code, corresponds to text held by the UI
String[] params; // specific parameters to be substitued in the error text
// CUTSOMER and ORDER in my example above
int SystemErrorCode; // If you have an underlying error code it goes here
String SystemErrorText; // any further diagnoistic you might need to give to
// the user so that they can report the problem to the
// help desk.
// OR instead of the text (this is something I've seen done)
int SystemErrorTag; // A unique id for this particular error problem.
// This server systems will label their message in the
// server logs. Users just tell the help desk this number
// they don't need to read detailed server error text.
}