Discovery API failing with JSON error - c#

I have a very simple program meant to use the Google Discovery API. However, when I try to use the getRest call, it fails as below. Any ideas? I'm using the most recent version of the Discovery API from NuGet, VS 2012 Pro.
DiscoveryService service = new DiscoveryService(new Google.Apis.Services.BaseClientService.Initializer());
//this works no problem
service.Apis.List().Execute();
//this works on the API reference page's Try It! area, but fails here
service.Apis.GetRest("admin", "directory_v1").Execute();
This is the resulting error that is thrown in the Google.Apis.Requests.ClientServiceRequest class, on the Execute() method - line 96:
JsonSerializationException was unhandled
Additional content found in JSON reference object. A JSON reference object should only have a $ref property. Path 'schemas.User.properties.name.description', line 1251, position 20.

This is a documented error. Get the generated discovery to discovery its own discovery document #79
The only work around I have currently found is to use the Client lib to log in and then manually make my requests from the Discovery API. Its messy and doesn't work very well because you can use the class structure that the Discovery API class library would have given you.

Related

WSE 3.0 WSE839 Exception

There is a Java-Soap-Service which I want to call with WSE 3.0, I generated a Proxy with the WSDL-File but the service expects MTOM for it´s data.
I also followed this tutorial and it worked well but didn´t helped:
http://twit88.com/blog/2008/05/14/net-mtom-enabled-your-application-using-wse/
The Exception I get is:
System.FormatException: "WSE839: An HTTP response was received that used the following content type: text/xml;charset=UTF-8. The following content type was expected: multipart/related; type=application/xop+xml."
I know WSE 3.0 is obsolete if there is an other way to do it please tell.
Can some one please help?
Change your generated classes base class from System.Web.Services.Protocols.SoapHttpClientProtocol to Microsoft.Web.Services3.WebServicesClientProtocol. Once that is done you will be able to access a field called RequireMtom. Set this to true prior to calling any method that needs to send MTOM. Make sure to disable it for non MTOM calls.

Universal windows platform - Consuming web service, ASMX (Content type parsing)

I'm getting started with UWP and wish to consume an old, heavily used ASMX web service written in VB.Net 2.0.
I have created a service reference to the web service but whatever function I call I always end up with the error
"An exception of type 'System.PlatformNotSupportedException' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: MessageEncoder content type parsing is not supported."
There's no further help than this, not sure if it's because the return type is XML and it's expecting JSON or something, even if that were the case I see nowhere to change this.
Here is the relevant lines that I am using to pull back a simple response, help would be greatly appreciated.
WSSoapClient proxy = new WSSoapClient();
Guid ProviderGUID = Guid.Parse("[REDACTED]");
string ProviderPassword = "[REDACTED]";
objWSEthnicitiesGetReturn result;
result = await proxy.WSEthnicitiesGetAsync(ProviderGUID, ProviderPassword);
I found the issue, while the W/S is using HTTP... during use the endpoint was changed to HTTP. Now while there is a redirect in IIS this caused the lookup to always return a 301 error.
In the reference file for the Service Reference I had to alter the proc GetBindingForEndpoint to include the following lines
result.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.None;
result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
Whilst bringing the reference into the project .NET had also changed all references to the HTTPS to HTTP so I had to do a search for all instances throughout the project and manually change them all.
All is good now though so thank you for your time guys.

Server returned an invalid soap fault when calling operation from class library

I am using Visual Studio 2012. I have a ASP.NET MVC 4 web app that references a class library. This class library has a service reference. The service reference I added by inserting the URL to the .wsdl file.
I have set up everything correctly. When I do a call to one of the operations then I get an error:
Server returned an invalid SOAP Fault. Please see InnerException for more details.
Then when I view the inner exception:
The data at the root level is invalid. Line 16, position 17.
I am doing everything right, I just don't know why I get this error when I do a call to one of the operations. Where do I see what is returned? I have no control over this service, I am just consuming it.
Run fiddler while making the request. http://fiddler2.com/
This will allow you to see what is actually being sent and what is actually being returned

Custom Tool Warning error verifying some XML Schemas during export

I have a web service that I want to consume driven by PHP and SOAP. I can add the web service just fine and I get the list of methods when I added(used add service reference when added). But now I get an error:
Warning 1 Custom tool warning: There was an error verifying some XML Schemas generated during export:
Type 'http://www.w3.org/2001/XMLSchema:struct' is not declared. localPATH:Reference.svcmap 1 1 SOAP_Webservice_Test
From what I understand, this is due to a specific type that I have in my PHP Soap API. I have googled but none of the mentioned fixes does it for me.
Any suggestions how to proceed with my debugging?
Closing this because the problem was not in the client, it was in the soap server I tried to refer to.

Problem regarding consuming php web service in c# Desktop application

I am developing a c# desktop application and using a webservies which is developed in a php application when i try to consume that application. I just add web REference of that web service and try to access throught the following code
WebReference.TestWSDL pdl = new testingApp.WebReference.TestWSDL();
string copy = pdl.verify("testing");
it throws the error when i try to call the method verify. the error is
Possible SOAP version mismatch: Envelope namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/.
and the web service link was like
http://171.139.101.12/code/index.php/webservice/wsdl
The error you are encountering is informing you that when you invoke the webservice, you are being given the WSDL (Web Service Definition Language) for the service - this is the metadata that describes the service functions, but cannot actually be used to invoke the service. Usually, you access the WSDL by appending either "?wsdl" or "wsdl" to the service URI.
There are two elements to the webservice you are attempting to consume.
The actual service exists at:
http://171.139.101.12/code/index.php/webservice
The metadata describing it, which Visual Studio via wsdl.exe used to generate a proxy, resides here:
http://171.139.101.12/code/index.php/webservice/wsdl
You need to edit the properties of the Web Reference and update the address appropriately. Alternatively, you can alter the properties of the pdl variable, and change the endpoint in code.

Categories