10 messaggi dal 27 settembre 2012
Ciao,

sto tentando di usare (consumare) un metodo messo a disposizione da un web Service (scritto in Java) con windows phone 8.

Il codice che uso è il seguente:

try
{
WebServiceClient ws = new WebServiceClient();
MessageBox.Show("Creato WebService Client!");

ws.myMethodDataCompleted += finito;// new EventHandler<myMethodDataCompletedEventArgs>(finito);

ws.myMethodDataAsync();

}
catch (Exception e)
{
MessageBox.Show("Errore generico");
}

//...

private void finito(object sender,myMethodDataCompletedEventArgs e)
{
MessageBox.Show("Città: " + e.Result.citta);
}


L'esecuzione del codice (su win 8.1 Pro Preview e debug sul device fisico, un Nokia Lumia), sollev una eccezione:

'System.ServiceModel.CommunicationException' in System.ServiceModel.ni.dll non gestita nel codice utente

in una riga di reference.cs

Non riesco a capire quale possa essere il problema. Lato server, apparentemente è tutto ok (lo stesso metodo del web service lo uso con successo in una app WinRT/8).

Qualche suggerimento?
guarda l'innerexception o comunque lo stack trace. probabilmente c'è qualcosa che non va.

il fatto che funzioni da altre parti non conta, ci sono serializzatori differenti in gioco.

Daniele Bochicchio | ASPItalia.com | Libri
Chief Operating Officer@iCubed
Microsoft Regional Director & MVP
10 messaggi dal 27 settembre 2012
In cima all'innerexception ho questo errore:

$exception{System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)


Purtroppo non saprei estrapolare informazioni importanti da qui, anche perchè non ho mai fatto un debug serio con visualstudio.

Noto solo che il server ritorna l'errore "non trovato". Ma non trovato...cosa?
potrebbe essere che vada in errore perché di default non viene passato uno user agent. qui c'è uno spunto.

Daniele Bochicchio | ASPItalia.com | Libri
Chief Operating Officer@iCubed
Microsoft Regional Director & MVP
10 messaggi dal 27 settembre 2012
Sono riuscito a risolvere il problema inserendo l'indirizzo IP del PC su cui gira il webservice, al posto di "localhost" nel riferimento al servizio web.

Però...non capisco perchè il mio codice non intercetta l'eccezione sollevata e non riesco nemmeno a far intercettare una EndpointNotFoundException che mi sarebbe utile proprio per comunicare all'utente che il server non è raggiungibile...

(In realtà, se il server è irraggiungibile, non riesco ad intercettare nessuna eccezione, il mio codice infatti cerca di "catchare" una Exception generica, ma, nulla di fatto :/ )
59 messaggi dal 17 maggio 2010
Ciao,
prova così :
private void finito(object sender, myMethodDataCompletedEventArgs e)
        {
            try
            {
                if (e.Error != null) throw e.Error;
                MessageBox.Show("Città: " + e.Result.citta);
                //è preferibile usare uno string.Format:
                //MessageBox.Show(string.Format("Città: {0}",e.Result.citta));
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }


o più semplicemente :

private void finito(object sender, myMethodDataCompletedEventArgs e)
        {
           if (e.Error != null) MessageBox.Show(e.Error.Message);
           else MessageBox.Show("Città: " + e.Result.citta);
        }

Modificato da u235 il 29 settembre 2013 03.44 -
14 messaggi dal 05 dicembre 2006
hinge16.eu
Ciao,
ho lo stesso medesimo errore su un progetto per wp8 che richiama un servizio wcf che a sua volta consuma un servizio SOAP.

Ho provato tutte le soluzioni indicate in questo post, ma nulla, ottengo sempre lo stesso errore.

L'eccezione che ricevo è la seguente:
System.ServiceModel.CommunicationException non è stata gestita dal codice utente
HResult=-2146233087
Message=The remote server returned an error: NotFound.
Source=System.ServiceModel
StackTrace:
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at EasyPark.WP8.Test.EasyParkManager.EasyParkServiceClient.EasyParkServiceClientChannel.EndCheckParking(IAsyncResult result)
at EasyPark.WP8.Test.EasyParkManager.EasyParkServiceClient.EasyPark.WP8.Test.EasyParkManager.IEasyParkService.EndCheckParking(IAsyncResult result)
at EasyPark.WP8.Test.EasyParkManager.EasyParkServiceClient.OnEndCheckParking(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
InnerException: System.Net.WebException
HResult=-2146233079
Message=The remote server returned an error: NotFound.
Source=System.Windows
StackTrace:
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
InnerException: System.Net.WebException
HResult=-2146233079
Message=The remote server returned an error: NotFound.
Source=System.Windows
StackTrace:
at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClasse.<EndGetResponse>b__d(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass1.<BeginOnUI>b__0(Object sendState)
InnerException:

Simone Sanfilippo

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.