Log In
Developer Network
Technologies
Join the Network
Member Services
Events & Community
Extension Mobility API (EMAPI) Developer Center
Overview
Documentation
Community
Wiki
Testing
Everything
This Site
Blogs
9.1 Mobility API Documentation Now Available
Ting-Hao Chen
| 10 Jan 2013
Tweet
Check out the new content on the Cisco Developer Network reflecting the New & Enhanced features in Cisco Unified Communication Manager 9.1.
See the new
...Read More
Unified Communications 9.0 Partner Bundle Offer Now Available to Order
Amanda Whaley
| 21 Sep 2012
Tweet
The Unified Communications 9.0 Partner Bundle packages Cisco’s Collaboration application software for our Collaboration partner community to leverage for their internal lab or demonstration systems. The 9.0 version is now available for order.
Learn More >>
...Read More
Unified CM 9.0(1) Developer Guides
George Gary
| 26 Aug 2012
Tweet
Cisco Extension Mobility Developers:
Check out the new content on the Cisco Developer Network reflecting the New & Enhanced features in Cisco Unified Communication Manager 9.0(1).
...Read More
Developer Partner 2012 US Update Presentations Available
George Gary
| 29 Jun 2012
Tweet
Developer Partners,
Cisco announces the availability of our 2012 Developer Partner presentations shared at CiscoLive San Diego.
Please log into the Cisco Developer Network using your Partner UserID to download this content.
Access these presentations here:
http://developer.cisco.com/web/cdc/devforumpreso
PARTNER LOGIN REQUIRED
...Read More
Developer Partner 2012 London Update Presentations Available
George Gary
| 10 Feb 2012
Tweet
Developer Partners,
Cisco announces the availability of our 2012 Developer Partner presentations shared at CiscoLive London.
Please log into the Cisco Developer Network using your Partner UserID to download this content.
Access these presentations here:
http://developer.cisco.com/web/cdc/devforumpreso
PARTNER LOGIN REQUIRED
...Read More
Showing 1 - 5 of 21 results.
Items per Page 5
Page
(Changing the value of this field will reload the page.)
1
2
3
4
5
of 5
First
Previous
Next
Last
Forums
Message Boards Home
Recent Posts
Statistics
Answer
(
Unmark
)
Mark as an Answer
« Back to Extension Mobility API Questions
java class to submit XML to EMServiceServlet
Threads [
Previous
|
Next
]
Chase Casanova
Posts:
2
Join Date:
2/18/10
Recent Posts
java class to submit XML to EMServiceServlet
emapi
java
xml
Answer
2/27/10 1:20 AM
Mark as an Answer
Submit
Reply with Quote
Quick Reply
I am trying to write a java class that will submit an XML request to the EMServiceServlet.
What I have now returns a 500 Internal Server Error, just like if I were to visit the servlet with a web browser.
So I think my problem is with my headers, but I can't be sure.
Does anyone see anything wrong with my code?
import java.io.*;
import java.net.*;
public class EMLoginLogout {
public static String emLogin(String userid, String phoneName, String appID, String appPasswd) {
// Build XML String
String XMLString = new String();
XMLString = "<request>";
XMLString += "<appInfo>";
XMLString += "<appID>" + appID + "</appID>";
XMLString += "<appCertificate>" + appPasswd + "</appCertificate>";
XMLString += "</appInfo>";
XMLString += "<login>";
XMLString += "<deviceName>" + phoneName + "</deviceName>";
XMLString += "<userID>" + userid + "</userID>";
XMLString += "<exclusiveDuration>";
XMLString += "<time>60</time>";
XMLString += "</exclusiveDuration>";
XMLString += "</login>";
XMLString += "</request>";
try {
// Make connection
URL url = new URL("http://X.X.X.X:8080/emservice/EMServiceServlet");
URLConnection urlConnection = url.openConnection();
urlConnection.setRequestProperty("Content-Type", "text/xml; charset=\"utf-8\"");
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.connect();
OutputStreamWriter out = new OutputStreamWriter(urlConnection.getOutputStream(),"UTF8");
// Write XML string to request body
out.write(XMLString);
out.flush();
// Read the response
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String line = null;
while ((line = in.readLine()) != null)
{
//System.out.println(line);
line += in.readLine();
}
out.close();
in.close();
return line;
}
catch (UnknownHostException e) {
System.err.println("Error connecting to host: " + e.getMessage());
return "-2";
} catch (IOException ioe) {
System.err.println("Error sending/receiving from server: " + ioe.getMessage()); // close the socket
} catch (Exception ea) {
System.err.println("Unknown exception " + ea.getMessage());
return "-3";
}
return XMLString;
}
}
Thanks,
-C
Sign in to vote.
Flag
Please sign in to flag this as inappropriate.
Top
Stephan Steiner
Posts:
4
Join Date:
6/17/08
Recent Posts
RE: java class to submit XML to EMServiceServlet
Answer
3/1/10 9:26 PM as a reply to Chase Casanova.
Mark as an Answer
Submit
Reply with Quote
Quick Reply
Three thing:
1) You're missing authentication.. (basic authentication header)
2) Content type is wrong.. nedds to be application/x-www-form-urlencoded
3) Content(XMLString) needs to be prepended by xml=
Check com\cisco\ipphone\sdk\EMProvider in the Cisco Ip Phone Services SDK for a working sample.
Sign in to vote.
Flag
Please sign in to flag this as inappropriate.
Top
Chase Casanova
Posts:
2
Join Date:
2/18/10
Recent Posts
RE: java class to submit XML to EMServiceServlet
Answer
3/1/10 11:06 PM as a reply to Stephan Steiner.
Mark as an Answer
Submit
Reply with Quote
Quick Reply
Thanks Stephan, I didn't realize this was already something that was part of the IPPhones SDK.
I just recreated the wheel!...woohoo!
-C
Sign in to vote.
Flag
Please sign in to flag this as inappropriate.
Top
dan dan
Posts:
3
Join Date:
3/12/10
Recent Posts
RE: java class to submit XML to EMServiceServlet
Answer
3/16/10 1:31 PM as a reply to Chase Casanova.
Mark as an Answer
Submit
Reply with Quote
Quick Reply
thanks ...
i was digging with that problem ,too.It returned 500 internal server error while using samples in normal way....
founding cisco's soap syntax is harder than founding a treasure....
there are no clear samples in sdk of emapi
Sign in to vote.
Flag
Please sign in to flag this as inappropriate.
Top
Collateral
No files available