ConcourseSuite Support

Support
Corporate
PUBLIC PROFILE

Back to topics

Discuss Data Import and Export

XML-API not working.. where is my mistake?

You need to be logged in to post messages

XML-API not working.. where is my mistake?

12/28/2005 12:28 PM EST (edited) by Moderator

Hi,
we are starting to play with import/export in Centric and we are running immediately in troubles :-)

According to Dark Horse Ventures XML API documentation (version 1.5 Octorber 18, 2004) we have first proceded to server setup:

Created an entry in [sync_client] with the following values:
type: web feeder
version:1
enteredby:0
modifiedby:0
enabled:true
code:---
clientid:2

Coded this little php snipped from your example:



<?PHP

$xmlDocument='<?xml version="1.0" encoding="utf-8"?>
<app>
<authentication>
<id>www.site.com</id>

---

<systemId>2</systemId>
</authentication>
<meta>
<property>id</property>
</meta>
<transaction id="1">
<ticket action="insert">
<problem><![CDATA[this is my first xml-API inserted ticket></problem>]]
<sourceCode>123</sourceCode>
<catCode>1</catCode>
<subCat1>2</subCat1>
<subCat2>3</subCat2>
<subCat3>4</subCat3>
</ticket>
</transaction>
</app>
';
// Site to post to
$server = "www.site.com";
$path = "/centric/ProcessPacket.do";
// Begin the transfer
$socket = fsockopen($server, 8080);
if (!$socket)
//echo" error: could not connect to server";
// return
} else
// Post the XML document
$request = "POST " . $path . " HTTP/1.0\r\n" .
"Host: " . $server . "\r\n" .
"Content-Type: text/xml\r\n" .
"Content-Length: " . strlen($xmlDocument) . "\r\n\r\n" .
$xmlDocument;

if (!fputs($socket, $request, strlen($request)))
//echo"error: could not write to server";
// return
}
$response = ;
while ($data = fread($socket, 32768))
$response .= $data;
}
fclose($socket);
if ($response = )
echo "error: no response from server";
// return
} else
echo "-$response-";
}
}
//echo $xmlDocument;
?>


Running this has no effect and we do not receive any kind of response.. :-(

Looking on tomcat log we found this exception:


java.sql.SQLException: Sync Client record not found.
at org.aspcfs.modules.service.base.SyncClient.<init>(Unknown Source)
at org.aspcfs.modules.service.actions.ProcessPacket.executeCommandDefault(Unknown Source)
at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.darkhorseventures.framework.servlets.ControllerServlet.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)


According to documentation Systemid is "an id the server assigned to map the transaction to". We have tested with several values, also our "clientid" that is 2 but nothing.
It's not clear what value has to be used.

Objectname tag is not present in the xml of your example...

Action is "insert".

The exception seems to be about centric not be able to find our client record.
We do not understand if there is a problem with some "id"..
In the xml of the example there is no a tag in the authentication section for the clientid..
We are confused :-) :-)

Thank you

Lucio

1. 12/28/2005 12:52 PM EST

Within <authentication/> include <clientId>2<clientId/>. This should retrieve your client record.

We are currently upgrading our XML-HTTP API from v2.9 to work with later versions of Centric. Documentation also needs to be updated along with the API!

Ananth

2. 12/28/2005 1:57 PM EST
Default user photo

By Matt Rajkowski

Concursive Corporation
Product Design

airplane-icon-100x100.png

Also, the systemId should be 4. This maps to a table in Centric CRM that maps various object names allowed access by the client. You should also change your "code" value used above, now that others can see it here.

When working with XML documents though, the data should be encoded with a library.

3. 12/29/2005 4:18 AM EST

ok..
I have added clientid tag to the authentication section in xml.
I have setted systemid to 4.

I have also fixed a syntax error in php code that prevents response to be read from the socket:

if ($response == )
echo "error: no response from server";
// return
} else
echo "-$response-";
}

== and not = as in your example (php specs changed, i think, but this is not important...)

by the way now i'm able to connect :-) and i receive this response:

<?xml version="1.0" encoding="UTF-8"?><aspcfs><response><status>1</status><errorText>Error: rollback() should not be called while in auto-commit mode.</errorText></response></aspcfs>

My xml envelope is:

<?xml version="1.0" encoding="utf-8"?>
<app><authentication>
<id>cms.abd.it</id>

baluba

<systemId>4</systemId>
<clientId>2</clientId>
</authentication>
<meta>
<property>id</property>
</meta>
<transaction id="1">
<ticket action="insert">
<problem>questo è un ticket</problem>
<sourceCode>123</sourceCode>
<catCode>1</catCode>
<subCat1>2</subCat1>
<subCat2>3</subCat2>
<subCat3>4</subCat3>
</ticket></transaction>
</app>

I'm concious of the need to maintain reserved the "code baluba" value for authentication :-) - i'm only playng to understand.

I suspect i'm missing something more or your documentation is definitely non complete... :-(
maybe there is some properties to set about the nature of the transaction int he transaction section??

Where i can find the full list of object and properties i can manipulate with the xml-api??

I need to experiment with creation of tickets from external application, creation of leads from web site and so on...

Thank you very much.

Lucio

4. 12/29/2005 9:01 AM EST
Default user photo

By Matt Rajkowski

Concursive Corporation
Product Design

airplane-icon-100x100.png

Getting close then... you also need enteredBy and modifiedBy...

<transaction id="1">
<ticket action="insert">
<problem>questo è un ticket</problem>
<enteredBy>1</enteredBy>
<modifiedBy>1</modifiedBy>
</ticket>
</transaction>

5. 12/29/2005 11:12 AM EST

Hi Mat,
I've added
<enteredBy>1</enteredBy>
<modifiedBy>1</modifiedBy>
and also i've checked that "1" is the right value in the [sync_client] table for my client record (i have only one).

So my current client authentication record is:

type: web feeder
version:1
enteredby:1
modifiedby:1
enabled:true
code:---
clientid:2

Still the response from Centric is:

<?xml version="1.0" encoding="UTF-8"?>
<aspcfs>
<response>
<status>1</status>
<errorText>Error: rollback() should not be called while in auto-commit mode.</errorText>
</response>
</aspcfs>

I use MS SQL server if this help...

I've examinated all the documentation i bought but there is no other informations about http-xml.

Thank you.

Lucio

6. 12/29/2005 12:37 PM EST

Lucio,

<enteredby/> and <modifiedby/> value should point to a valid user in the database. Refer to the 'access' table to see if the user exists. These values DO NOT refer to your [sync_client], but to [access].

Let me know if this helps.

Ananth

7. 12/29/2005 1:07 PM EST
Default user photo

By Matt Rajkowski

Concursive Corporation
Product Design

airplane-icon-100x100.png

>> Error: rollback() should not be called while in auto-commit mode.

Thanks, this does help since MSSQL returns this error whereas other database servers do not when dealing with multiple commit() and rollback() in a single transaction.

Maybe the Centric CRM transaction code is incorrectly changing the AutoCommit and causing this to fail under MS SQL. I will try this code using MS SQL and report back.

8. 12/30/2005 3:30 AM EST

Ananth,
i've checked that <enteredby/> and <modifiedby/> value point to a valid user in the database. "2" is the contacID of me as a Centric user. it's a valid user, i can login and work.
Using 2 as the value for <enteredby/> and <modifiedby/> does not change anything.

Matt,
the ipotesi that Centric CRM transaction code is incorrectly changing the AutoCommit and causing this to fail under MS SQL may be a good candidate.
I will test this same code to another Centric installation using Postgress.

I will give my feedback about this test "asap".

Lucio

9. 12/30/2005 3:53 AM EST

mmhh
I've tested the same insert in another Centric installation with postgress.

The xml envelope is:

$xmlDocument='<?xml version="1.0" encoding="utf-8"?>
<app>
<authentication>
<id>contatti.abd.it</id>

---

<systemId>4</systemId>
<clientId>2</clientId>
</authentication>
<meta>
<property>id</property>
</meta>
<transaction id="1">
<ticket action="insert">
<problem>questo essere un ticket</problem>
<enteredBy>1</enteredBy>
<modifiedBy>1</modifiedBy>
<sourceCode>123</sourceCode>
<catCode>1</catCode>
<subCat1>2</subCat1>
<subCat2>3</subCat2>
<subCat3>4</subCat3>
</ticket>
</transaction>
</app>'

Where i've created the client record, i've checked that 1 is a valid user for <enteredBy> and <modifiedBy>. The "password is ok" and so on.

The result is:

<?xml version="1.0" encoding="UTF-8"?>
<aspcfs>
<response id="1">
<status>1</status>
<errorText>Transaction failed</errorText>
</response>
</aspcfs>

more cryptic than before :-)

Lucio

10. 12/30/2005 12:46 PM EST

Status 'Transaction Failed' indicates that authentication was successful. I guess there is something wrong with the transaction piece.

Can you verify if the following point to the corressponding tables?

<sourceCode>123</sourceCode> should refer to lookup_ticketsource (code)

<catCode>1</catCode>
<subCat1>2</subCat1>
<subCat2>3</subCat2>
<subCat3>4</subCat3>
should all refer to ticket_category(id)

<enteredBy>1</enteredBy>
<modifiedBy>1</modifiedBy>
should both refer to access(user_id)

12 results found