Can I stop service reference generating ArrayOfString instead of string[]? - c#

I have a web method with a signature like this:
public string[] ToUpper(string[] values)
I am using the 'Add Service reference' in Visual Studio 2010 to generate a reference to my service. Unfortunately, this process creates a proxy class called 'ArrayOfString' and uses this type instead of the expected 'string[]' type. The generated async service call signature ends up looking like this:
public void ToUpperAsync(Demo.ServiceReference.ArrayOfString values) { }
public void ToUpperAsync(Demo.ServiceReference.ArrayOfString values, object userState) { }
I have tried all the options of the 'Collection' drop down on the config service reference form and it doesn't seem the make a difference.
This was working previously, but for some reason it suddenly stopped working, perhaps after removing another web method from the service.
How do I get the generated service reference class to use the string[] type instead of a generated ArrayOfString type? Any help on this would be greatly appreciated.
EDIT:
As #Oleg suggests, I am using ASMX web services.

this change to XmlSerializer can ben done inside the Reference.svcmap file. Open it inside the Service Reference folder and change the Serializer xml node from "Auto" to "XmlSerializer" this solves the problem!
Cheers

I could reproduce your problem when adding a "Service reference" to an ASMX style web service. However when adding "Service refernce" to a WCF service or "Web reference" to an ASMX service argument was of type string[].
According to this I think that you can fix your problem by replacing "Service reference" by "Web reference".
Press "Advanced..." button on "Add service reference dialog".
Press "Add web reference..."
Insert service url and add web reference

Too late but can help people in the future...
Use the svcutil and explicitly inform the command line util that you want the proxy class to be serialized by the XmlSerializer and not the DataContractSerializer (default). Here's the sample:
svcutil /out:c:\Path\Proxy.cs /config:c:\Path\Proxy.config /async /serializer:XmlSerializer /namespace:*,YourNamespace http://www.domain.com/service/serviceURL.asmx
Note that the web service is an ASP.NET web service ok?!

Related

Type not defined error on calling Web Service

I have a web service whose reference i'm giving in my web site. The code in website where i'm defining my web service is below:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Script.Services
Imports System.Collections.Generic
Public Class APIUtilities
Private GD As GetDatFromMDB
Private _OfflineAPITest As Boolean = False
Private WSLK As com.teleasy.app1.WBLookup
End Class
I get error on this line: Private WSLK As com.teleasy.app1.WBLookup
Error message is this:
Please help. Answers in C# will also help.
Looks like you're trying to refer to the web service directly, using it's namespace. Don't do that; add a service reference to it instead (right click References in VS, click Add Service Reference, and enter the URL of the service.
When you add a service reference, the framework will generate classes for you that match the interface of the service, etc. These are the classes you want to use.
You can see info about the service and available methods by right clicking the reference (should now be visible under Service References), and selecting View in object browser.
The class you want to call to communicate with the service should be called something like NameOfTheServiceClient (i.e. your service-name with Client appended).

no overload method takes 2 arguments

Hi I have a WCF service and within it I have this method
void SendData(int pumpNo, List<String> pumpInfo);
however when I try to pass an int and a list into it, I get an error saying
Error 1 No overload for method 'SendData' takes 2 arguments
This is how I passed data to it in the WCF client
sendpumpdata.SendData(pumpID, pumpData);
ok so at the top I create an instance of the WCF service by doing...
ServiceReference1.iCommClient sendpumpdata = new Pumps.ServiceReference1.iCommClient();
also in my service.cs I have created the method defined in the IService.cs
A WCF web service leverages client generated code (i.e. a proxy) to communicate with the server. In your situation, even though the server code has two parameters, your client generated code must be out of date.
If you're using a Web Reference or a Service Reference just right click and Update Reference. If you're using a static WSDL then navigate to the WSDL hosted locally for the WCF service and save it to disk and then overwrite the one in your project.

How I set a reference to a SOAP file and use this functions in C#

I want create a ASP.NET Application (aspx site) that connection with a database and create userconnections for the internet. I get a Soap Data (soapapi.wsdl). This file have all function for create a guestuser or get Informations about who apply a GuestUser and the Time.
My Problem is that I don't know how I can add a reference to this Soap File in C# an execute this functions :( ? I search it but I don't found a good example :/
What I need for a Namespace and how i set a reference to this wsdl file ?
tarasov
Try to add Service Reference
Right click on project file ->Add Service Reference. In the dialog point to this wsdl file.
At result a proxy c# class will be generated, that allows you to call soap methods as usual code

Expose List<> in asmx service

Can I expose a System.Collections.Generic.List<> from a asmx service.
I tried it but the reference class generated at client have converted it as Arrary[].
Have you set the option in update service reference?
You can set this by right mouse clicking on your service located in the Service References folder, then select Configure Service Reference.
And may you have set that option already and your still getting back an array then may i suggest to look here
http://johnnblade.wordpress.com/2012/06/07/service-reference-returns-array-t-instead-of-listt/

How to override target URI for a web service reference in VS 2008

This seems like it should be really simple, but I'm unable to figure this out.
I am adding a web service reference to my console application. The web service points against our production environment and I would like to test it against development. In VS2005 it was really easy to override the target URI of the service. Is it possible to do the same with VS2008? I would like to set the URI in code or via a config file.
I would really appreciate help with this. Thanks!
If you look in your .config, you should see <endpoint> elements that were added to the <client> section of <system.serviceModel>. Assuming you need to point at only one environment at a time you can simply edit the address attribute of those endpoints to point to whatever URL you want.
If you wanted to change this at runtime you need to use the constructor overload for the client proxy that was created. There should be several overloads that take a parameter called remoteAddress in many forms.
It seems that I was able to get around this issue by going to "Add Service Reference" -> "Advanced" -> "Add Web Reference". This gives me a reference in the form I am most familiar with. Now I was able to override the constructor with the URI parameter. Is that method frowned upon?

Categories

Resources