Calling XmlInterop from C# via a COM object

Patrick Wensel

Member
I am a C# developer and am struggling!!!

I used this article which has been mentioned in JDEList to build a client for C#.

http://it.toolbox.com/blogs/daniel-at-work/calling-xmlinterop-from-c-via-a-com-object-20923

I am now running the console app to test it and i am getting:

<returnCode code='14'> Connection to OneWorld Failed</returnCode>

I have seen this message on the forums before but nothing has seemed to help. Here is my code:
C++

STDMETHODIMP CXmlinteropClass::jdeXmlRequest(BSTR request, BSTR* response , BSTR host, SHORT port, SHORT timeout)
{
CString csReq(request);
char* cRequest; cRequest = csReq.GetBuffer();
char* presp = jdeXMLRequest( (unsigned short*)host, port, timeout, (void*)cRequest, 0);
CComBSTR* foo = new CComBSTR();
foo->Append(presp);
*response = foo->Detach();
jdeFreeXMLResponse(presp);

return S_OK;
}

C#

static void Main(string[] args)
{
string response;
string request = @"<?xml version='1.0' encoding='utf-8'?> <jdeRequest pwd='Apple2' role='*ALL' type='callmethod' user='sduvedi' session='' environment='DV811' sessionidle=''> <callMethodTemplate name='GetAuditInfo' app='AwiIntegrations' /> </jdeRequest>";
string host = "10.8.66.107";
short port = 6014;
short timeout = 10000;
xmlinterop_comLib.XmlinteropClass foo = new xmlinterop_comLib.XmlinteropClass();
foo.jdeXmlRequest(request, out response, host, port, timeout);
Console.WriteLine(response);
Console.Read();
}
 
Patrick,

The fact that you are getting that particular response means you are calling the function (or the COM implementation is delegating it). Can you verify the IP address and the port of your enterprise server are correct?

On a side note, I see you are using a COM wrapper around the JDE API call. You can call this function directly from C# using DllImport (PInvoke), if you'd rather.

Craig
 
Back
Top