Google Search Results

Clear Results

WebCOBRA.com Community Message Boards

Creating Apps with the API

mhowell
Posts: 7
Since: 09/24/2007

Content Types not matching
01/31/2008 11:06 AMReply

After trying to write a simple interface to the WebAPI, I kept getting the same error. I have wrote code in VB.NET as well as C#, neither work and both give the same problem.

The problem is:

The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupport ed method is implemented properly. The first 1024 bytes of the response were: '

...

And my code is below. To create these probjects, I didn't do too much more than create a new console application project, add a service reference to "https://app.webcobr a.com/exec/api.asmx", and type the code below (which just tries to log in). It breaks at run time.

Most of the code is taken directly from the query sample application from the DevCenter's Sample Code section. After looking at that code, it appears that the web reference it uses is to a local file (http://localhost/blankwebsite/API.asmx) and attempts to instaniate an API object, which I have not been able to do (the closest I can find is the APISoapClient object; I cannot verify that the WSDL is different since the one referenced is local).

Can an updated project be posted that uses the actual WSDL URI (https://app.webcobra.com/exec/api.asmx)?

Thanks, Matthew


' VB.NET Version:

Module wcTest1module
Sub Main()
Console.WriteLine("Initializing...")
Dim wcAPI As New WebCOBRA.API()
Dim credentials As WebCOBRA.ServiceCredentials

credentials = login(wcAPI)
End Sub

Public Function login(ByRef api As WebCOBRA.APISoapClient) As WebCOBRA.ServiceCredentials
login = Nothing

' Breaks on next line
login = api.Login("admin", "user", "password")
End Function
End Module

-------------------
// C# Version
using System;
using System.Collections.Generic;
using System.Text;

namespace wcTest2
{
class test2cs
{
static void Main(string[] args)
{
Console.WriteLine("Initializing....");

// Declare our API Object
WebCOBRA.APISoapClient API = new wcTest2.WebCOBRA.APISoapClient();
WebCOBRA.ServiceCredentials credits;

login(API);
}

public static WebCOBRA.ServiceCredentials login(WebCOBRA.APISoapClient api)
{
WebCOBRA.ServiceCredentials ret = null;

ret = api.Login("admin", "user", "password");

return ret;
}
}
}




jwolgamott
Posts: 257
Since: 09/26/2005

RE: Content Types not matching
01/31/2008 04:04 PMReply

The sample_query project that was compiled had the correct reference, but the code was indeed pointing to localhost. This has been corrected, so you can download the project and code from the Sample code section.

You can, however, download the WSDL directly from https://app.webcobra .com/exec/api.asmx?w sdl



Systems should be free (to interact with others)

mhowell
Posts: 7
Since: 09/24/2007

RE: Content Types not matching
02/08/2008 11:43 AMReply

Thanks, that update helped. I was also able to determine that, using Visual Studio 2008 (.NET 3.5), you need to add a web reference which is not the same as a service reference. Also, since the WSDL is on an HTTPS connection, after you add the web reference, VS does not save the HTTPS, essentially converting it to HTTP and you will get blank responses. You need to go into the .config file and add the 's' to the HTTP.



Return to Forum