WCF deserializing body error because of adding async behind the method name - wcf

I've created a WCF service with a method GetTestValue. I've also created a test application to test this service.
When I add this WCF service with connected service to the test application I can only call GetTestValueAsync, there is no GetTestValue method. Somehow this add process add this async thing behind the method name. So in this test application, the WCF call works fine when I call GetTestValueAsync. I get the result back.
Then I've created a Xamarin cross application app where I added this WCF service too, and when I call the GetTestValueAsync from this application I get the following error:
Error in deserializing body of request message for operation 'GetTestValue'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'GetTestValue' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'GetTestValueAsync' and namespace 'http://tempuri.org/'
Somehow strange in the test project it works fine, and in the Xamarin cross application not.
Did someone have the same problem?
Why is this connected service always this Async to my method name?
How can I stop this Async being added to the method name?
Thanks for any help.

At the moment Xamarin apps aren't compatible with the Task-based asynchronous WCF proxy methods that the WCF Web Service Reference connected service provider generates (bugzilla.xamarin.com Bug 51959).
One way to generate an older, compatible style of WCF proxy methods is to run SvcUtil.exe with the /async and /tcv:Version35 switches in a Developer Command Prompt. That will generate synchronous proxy methods, Begin/End style Asynchronous Programming Model (APM) callback proxy methods, and event-based proxy methods, all of which are compatible with Xamarin apps.
(Note: If you leave out the /async switch, SvcUtil.exe will generate the newer, incompatible Task-based proxy methods.)
Duplicate: By chance, I replied on a more recent duplicate of this question first:
How to use WCF services in .netstandard with Xamarin.Forms project?

I know this is old, but I had the same problem and searched a while. When you are adding the Reference in your project, you can check "generate synchronized operations" and the "Async"-suffix aren't generated anymore. My VS runs in german language, so I just translated the options. If your adding new methods the setting will be considered too.
Greetings from germany.

Related

Does WCF Add Service Reference require something configured on the service to generate the app config?

We have an existing wcf service, and I created a new project. I want to use it. I hit add service reference, pop in the URL, press OK, and it adds it as a service reference but there is no config generated.
I also tried svcutil.exe /language:cs /out:GeneratedProxy.cs /config:app.config [url] but no config is generated, only the proxy cs.
I'm using VS 2013 / .NET 4.0
My question is, is this a sign that the SVC itself has some missing data that is required to build the contracts, or is the problem with adding the service reference?
For the record I have tried unchecking the reuse types option which some questions on here have reported as fixing the problem.
Bonus question, do you think if I can't get this working that manually adding some generic default bindings and endpoint code to the web config will work?
First, the reason that why the Adding service reference generates nothing is that the WCF service is rest style service. By default, the proxy-based invocation of rest style WCF services is complex.
https://en.wikipedia.org/wiki/Representational_state_transfer
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/wcf-web-http-programming-model
Calling the WCF rest style service with the client proxy is uncommon. Generally, we construct an Http request by using an HTTP client library to call the service, such as HttpClient, WebClient.
How to fix "ERR_ABORTED 400 (Bad Request)" error with Jquery call to C# WCF service?
Besides, calling the WCF rest style service with the client proxy is feasible. Please refer to my previous link.
WCF: There was no endpoint listening at, that could accept the message
Feel free to let me know if there is anything I can help with.

How to use WCF services in .netstandard with Xamarin.Forms project?

I've created a Xamarin.Forms project with .netstandard 2.0 as PCL project. I'm trying to consume WCF services in that project. I've added the connected service for WCF service. When I'm trying to call any method provided in the service, it gives the error as below:
System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail,
System.ServiceModel, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35]]: Error in deserializing body of
request message for operation 'GetData'. OperationFormatter
encountered an invalid Message body. Expected to find node type
'Element' with name 'GetData' and namespace 'http://tempuri.org/'.
Found node type 'Element' with name 'GetDataAsync' and namespace
'http://tempuri.org/'
I've also tried to change the .netstandard version to an older version but it gives the same error.
At the moment Xamarin apps aren't compatible with the Task-based asynchronous WCF proxy methods that the WCF Web Service Reference connected service provider generates for .NET Standard projects (bugzilla.xamarin.com Bug 51959).
One way to generate an older, compatible style of WCF proxy methods is to run SvcUtil.exe with the /async and /tcv:Version35 switches in a Developer Command Prompt. That will generate synchronous proxy methods, Begin/End style Asynchronous Programming Model (APM) callback proxy methods, and event-based proxy methods, all of which are compatible with Xamarin apps.
(Note: If you leave out the /async switch, SvcUtil.exe will generate the newer, incompatible Task-based proxy methods.)
Generate an older compatible style of WCF proxy methods via checked "Generate Synchronous Operations" checkbox on Configure WCF Web Service Reference screen:
Consume the web service:
KimlikServiceReference.KPSPublicSoapClient soapClient = new KimlikServiceReference.KPSPublicSoapClient(KimlikServiceReference.KPSPublicSoapClient.EndpointConfiguration.KPSPublicSoap);
//KimlikServiceReference.TCKimlikNoDogrulaResponse response = soapClient.TCKimlikNoDogrulaAsync(TCKimlikNo, Ad, Soyad, DogumYili).Result;
bool result = soapClient.TCKimlikNoDogrula(TCKimlikNo, Ad, Soyad, DogumYili);

wcf service calling an ASMX web service which returns IPropertyChangedEventHandler

Ok this is kind of a complicated situation so let me start by laying out what I'm trying to do.
I have a WCF web service that is using DataContractFormat to serialize requests as JSON. One of the clients of the web service generates a reference file using my wsdl and uses the soap endpoint on his end to make calls back and forth. Until now, this has been working great because we have had the ability to provide support for SOAP and also REST/JSON requests.
Our current project required us to include methods from RSA which exposes their webservice with a wsdl. So we are basically doing SOAP calls to them, and generating a reference file on our end and then using the classes and methods generated in our web service.
The problem we are getting is that the client is getting build errors in reference to not being able to serialize IPropertyChangedEventHandler which is included in all of RSA's classes. What I suspect is the problem is that RSA's classes are all defined using the System.Xml.Serialization methods and my web service is written to use the DataContractFormat instead of XMLSerializerFormat so it doesn't know how to serialize the classes. How do I get around this without completely rewriting the reference file using DataContract? Or is there possibly something else I might be overlooking?
Let me know if you need more details.
A coworker was able to figure out how to generate the RSA wsdl without the PropertyChangeEventHandler in the methods. We were able to get the reference file to generate without PropertyChanged by changing the svcmap file under the Service Reference folder
<EnableDataBinding>false</EnableDataBinding>
After changing this, we updated the service reference and all the PropertyChanged stuff was gone and we no longer got build errors.

Build subscription alerts for service changes

I am using Biztalk UDDI V3 (stand-alone install) on a windows 2008. I have configured all services (web, database and subscription):
I successfully published a couple of services
I successfully accessed and retrieved service information from my .net console application.
My issue at this point is with the subscription service. I tried to subscribe to one of the published services only to find out that I need to create my own listener.
I followed the steps listed here. Please take a look at the section entitled "Building subscription alerts for service changes". I am confused as to what the WCF service I create is supposed to look like. The instructions state the following:
Now we create a new WCF Service project and reference this existing service library. After making sure the .svc file points to our referenced library object, and adding a valid endpoint configuration file, view our service in the web browser to ensure that it's up and running.
I find this section confusing. Not sure what public methods would the WCF service expose(if any at all) or how to expose the functionality within the service library that I just referenced from within my WCF project.
Of course, if you know of a different way to achieve what I am trying to accomplish, that also would be much appreciated.
Thank you.
This may help. I actually just wrote a complete port for Apache jUDDI's client library using .NET C#. One of the use cases is actually what you are attempting to do. Here's the rough approach used.
Generate the code from wsdl (using wsdl.exe, because svcutil doesn't like the UDDI wsdls)
Alter the interface code to have WCF bindings for the Subscription Listener class
Create an implementation of the subscription listener and handle the callbacks
Fire up the implementation using WCF's embedded service
Register your sub listener endpoint with UDDI (using the correct annotations per the spec)
Setup the subscription using your sub listener's binding template
Wait for callbacks
Here's the code
http://svn.apache.org/repos/asf/juddi/trunk/juddi-client.net/
Example
http://svn.apache.org/repos/asf/juddi/trunk/juddi-client.net/juddi-client.net-sample/org.apache.juddi.client.samples/SubscriptionCallbackExample.cs
There's also a Java version that does the exact same thing.

Adding Service Reference for a Web Reference

I've started working on Windows Phone 7 and came across this problem.
I have a VS 08 console application that has a Web reference added to it and every thing works great, I have previously worked with Service Reference in WP7 and used the proxy classes.
I am not good in server side stuff and am not sure about the difference between Web and Service References i think Service refernce is for WCF only and Web supports SOAP as well, Any ways now i need to use that web Reference which is using SOAP Protocol in WP7 but when i add it as Service reference it doesn't show all proxy classes in object explorer.
Wasted 2 days in googling this and still I am not sure where to start. kindly Let me know if you have any questions.
Please HELP !
You should be able to add the web reference and coding for it will be similar to coding in your console app.
The main differences will be that WP7 requires you to use Asynchronous coding - i.e. instead of calling the service like a normal method, instead you have to pass in an event handler for when the web service call returns.
A partial tutorial is available within this article -
http://msdn.microsoft.com/en-us/magazine/ff872395.aspx - start at "Figure 6 Adding a SOAP Service Reference"
There are also some additional limitations in the WP7 implementation - e.g. it's harder to send certain things like soap headers - but hopefully your SOAP service will work OK.