Deserialization issue when consuming ASMX Web Service from Xamarin Android .NET6 App - web-services

Android application type: Android for .NET (net6.0-android)
Affected platform version: VS 2022 Version 17.3.0 Preview 5.0 (64 bit)
I'm upgrading an existing Xamarin Traditional (Android) application into .NET 6 but I'm running into deserialization problems. Our Android app integrates with a .NET Framework 4.8 ASMX Web Service on the backend. This has been working fine for years but doesn't work after we move to .NET 6.
I was able to create a repro project on my GitHub: https://github.com/adolfo1981/Net6AndroidWebServiceTest
Here are the details from deserialization error.
Exception:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:HelloWorldResponse. The InnerException message was 'There was an error deserializing the object of type ServiceReference1.HelloWorldResponseBody. Unexpected end of file. Following elements are not closed: HelloWorldResult, HelloWorldResponse, Body, Envelope. Line 1, position 298.'. Please see InnerException for more details.
StackTrace:
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)
at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader, XmlObjectSerializer serializer) in /_/src/System.Private.ServiceModel/src/System/ServiceModel/Dispatcher/DataContractSerializerOperationFormatter.cs:line 657
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader) in /_/src/System.Private.ServiceModel/src/System/ServiceModel/Dispatcher/DataContractSerializerOperationFormatter.cs:line 652
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest) in /_/src/System.Private.ServiceModel/src/System/ServiceModel/Dispatcher/DataContractSerializerOperationFormatter.cs:line 521
My GitHub repro repo consists of the following projects:
HelloAndroid (NET6 - .net6.0-android Target Framework Moniker)
WebServiceServer (.NET Framework 4.8)
WebServiceClient (.NET 6) --> referenced by HelloAndroid project to consume ASMX Web
Services
ClientTestConsole (NET6 Console app) - to prove that Web Service works fine directly from console app (but fails from Xamarin Android)
Steps to Reproduce
Create a Xamarin Android (NET 6) project similar to #jamesmontemagno https://github.com/jamesmontemagno/net6-mobile-samples/tree/main/HelloAndroid
Create a .NET Framework 4.8 WebServiceServer application following instructions like this: https://www.c-sharpcorner.com/article/how-to-create-a-web-service-project-in-net-using-visual-studio/
Create a .NET 6 (Class Library) WebServiceClient and add a Connected Service -> Web Service pointing to a wsdl or deployed asmx file
From Main Activity create an instance of the generated soap client and call HelloWorldAsync method:
var soapClient = new WebServiceSoapClient(WebServiceSoapClient.EndpointConfiguration.WebServiceSoap);
//Async test
var helloResponse = await soapClient.HelloWorldAsync();
Expected Result: Get string response from HelloWorldAsync() method
Actual Result: I get the deserialization issue mentioned above
I have posted this issue into Microsoft Xamarin Android GitHub but still waiting for reply: https://github.com/xamarin/xamarin-android/issues/7230
I also configured my Xamarin Android app to use Fiddler Proxy and captured Soap request and response and compared them with the request and responses from my Console App and didn't find significant differences. Those are shown in this comment: https://github.com/xamarin/xamarin-android/issues/7230#issuecomment-1207297030

Related

.Net Core 3.1 Connected services to webservice causes fault

I want to connect to https://wsiinst.uni-login.dk/wsiinst-v4/ws?WSDL.
This works fine in normal .NET 4.7.
But in .NET Core 3.1, the channel is Fault, when creating the Client..
My steps..
create .NEt Core console App
Add Connected service (Microsoft WCF Web Service Reference Provider) , call it "ServiceRef"
Add this code to program.cs (main)
var client= new ServiceRef.WsiInstPortTypeClient();
The client is created, but state is Faulted
Perhaps web service uses something, not supported yet in core ?
Anyone have an idea or canb point me in a direction ? :-)
It's the same, when you add connected reference you click in other references, that you will get the service endpoint and you have to put the URI. you click GO and will get the service avaliable. If this isn't working that's mean you have a problem in the serverside. Did you bind your port correctly??
check this link https://learn.microsoft.com/en-us/windows-server/networking/technologies/netsh/netsh-http
after you initalize the serviveref did you open the connection?
var client = new ServiceRef.WsiInstPortTypeClient();
await client.OpenAsync();
var getanobject = await client.MyobjectAsync();

Consuming webservice from application deployed on websphere

I have been trying to consume a webservice(WS-JAX) in java.
I have generated JAVA artifacts using wsimport tool. I constructed a standalone test class(on eclipse) and was able to call the webservice successfully.
But when I use the same actifacts and code in my application(deployed on websphere 8) I get below exception
`
[2/5/16 10:54:13:531 MST] FFDC Exception:java.lang.StackOverflowError SourceId:com.ibm.ejs.container.RemoteExceptionMappingStrategy.setUncheckedException ProbeId:200 Reporter:com.ibm.ejs.container.RemoteExceptionMappingStrategy#625fad44
java.lang.StackOverflowError
at java.util.HashMap.<init>(HashMap.java:367)
at com.ibm.wsdl.DefinitionImpl.getAllServices(DefinitionImpl.java:859)
at com.ibm.wsdl.DefinitionImpl.getAllServices(DefinitionImpl.java:873)
at org.apache.axis2.wsdl.util.WSDLWrapperReloadImpl.getAllServices(WSDLWrapperReloadImpl.java:903)
at org.apache.axis2.wsdl.util.WSDLDefinitionWrapper.getAllServices(WSDLDefinitionWrapper.java:478)
at com.ibm.wspolicy.wsdl.internal.subject.DefinitionSubjectProcessor.<init>(DefinitionSubjectProcessor.java:60)
at com.ibm.wspolicy.wsdl.internal.WSDLProcessorImpl.buildWSDLPolicyModel(WSDLProcessorImpl.java:79)
at com.ibm.ws.wspolicy.wsdl.WSDLProcessor.<init>(WSDLProcessor.java:137)
at com.ibm.ws.wspolicy.policyset.WSDLHelperImpl.processWSPolicyInPackagedWSDL(WSDLHelperImpl.java:80)
at com.ibm.ws.websvcs.deployment.WASAxis2PolicySetConfigurator.associatePolicySets(WASAxis2PolicySetConfigurator.java:385)
at com.ibm.ws.websvcs.client.WSClientConfigurationFactory.completeAxis2Configuration(WSClientConfigurationFactory.java:459)
at org.apache.axis2.jaxws.description.impl.EndpointDescriptionImpl.<init>(EndpointDescriptionImpl.java:286)
at org.apache.axis2.jaxws.description.impl.EndpointDescriptionImpl.<init>(EndpointDescriptionImpl.java:223)
at org.apache.axis2.jaxws.description.impl.ServiceDescriptionImpl.updateEndpointDescription(ServiceDescriptionImpl.java:534)
at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.updateEndpoint(DescriptionFactoryImpl.java:382)
at org.apache.axis2.jaxws.description.DescriptionFactory.updateEndpoint(DescriptionFactory.java:180)
at org.apache.axis2.jaxws.spi.ServiceDelegate.getPort(ServiceDelegate.java:597)
at org.apache.axis2.jaxws.spi.ServiceDelegate.getPort(ServiceDelegate.java:513)
at javax.xml.ws.Service.getPort(Service.java:99)`
Could someone shed some light on why the webservice call is failing when it is originating inside a application server?
Note: I have installed proper server certificates in the application server truststore.
So i found the solution, I had 2 different JRE's installed on my computer. One was from Oracle and the other was the jre bundled with websphere application server. For a application to be deployed on Websphere we have to generate the java artifacts using the IBM jre thats bundled with Websphere.
Thanks,
Harsha

Duplicate Request Virtual Machine Azure

I have a WebService running in a Virtual Machine, when I try include one register from the application, I'm receiving 3 requests and duplicating.
I have migrated a service to microsoft azure-cloud-services and start getting triplicate POST request from an Android APP client. Web container used : Tomcat8 (I have tested on 7 too) Rest api: jersey Problem: we have a rest service which is consumed by mobile client (android app), and for unknown reason POSTs (only POSTs) requests are going trice (3x). This is not our code, so when i checked the logs, I've notice that 3+ hibernate sessions are being created. Also I saw that hibernate sessions are being opened in a filter that is there in order to set service charset.
actually, I'm who is working on this so I can give more details.
Web container used : Tomcat8 (I have tested on 7 too)
Rest api: jersey
problem: we have a rest service which is consumed by mobile client (android app), and for unknown reason POSTs (only POSTs) requests are going trice (3x). This is not our code, so when i checked the logs, I've notice that 3+ hibernate sessions are being created. Also I saw that hibernate sessions are being opened in a filter that is there in order to set service charset.

Not able to generate server-config.wsdd using Eclipse and Tomcat 7.0

I am trying to generate the Web Service using the the following steps but could not generate the server-config.wsdd and the below message is shown:
**Jul 04, 2013 10:51:23 PM org.apache.axis.configuration.EngineConfigurationFactoryServlet getServerEngineConfig
SEVERE: Unable to find config file. Creating new servlet engine config file: /WEB-INF/server-config.wsdd**
Eclipse Version : Juno bit
Tomcat Version: 7.0.41 32 bit
Platform: Windows 7 32 bit
JRE: jre7
Steps:
Create Dynamic Web Project and assiciate it with
Create Class under package: com.sample.service.SampleWebService.java
Click on File/New/Others/Web Service project.
Choose Bottom Up Java Bean Web Service as Web Service Type
Provide the Path of the Java File along with the above mention package.
Choose Tomcat as server and Axis as Web Service Rum Time
Click Next and then choose the method to be exposed as web service
Rename the WSDL File Name in the Text Box
Style Use: document/literal (wrapped)
Click Next
Press Start Server.
Press Next:
Exception:
**faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.lang.NumberFormatException: For input string:"HTML";**
Note: This is simple Web service and I haven't used Annotation.

asp.net (asmx) webservices not working in windows phone 7

I am developing a wp7 app that consumes a simple web service written in asp.net
The web service is working fine in desktop application (written in c#) (also tested in web browser and is working fine) but it is not working in wp7.
Following is the code I am using in wp7 to call the webservice
BookService.BooklocationSoapClient client = new BookService.BooklocationSoapClient();
client.BookListCompleted += new EventHandler<BookService.BookListCompletedEventArgs>(client_BookListCompleted);
client.BookListAsync(dId);
void client_BookListCompleted(object sender, BookService.BookListCompletedEventArgs e)
{
Debug.WriteLine(e.Result);
}
and following is the exception I am getting
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll
A first chance exception of type 'System.ServiceModel.FaultException' occurred in System.ServiceModel.dll
A first chance exception of type 'System.ServiceModel.FaultException' occurred in System.ServiceModel.dll
Also, I am getting the following message
Server was unable to process request. ---> Length cannot be less than zero.
Parameter name: length
Seems like you try to call local web service on your developer machine, which not allowed by
windows phone emulator.
Try call any public web service available in internet, as example weather forecast