06-08-2011 12:58 AM
I need to interface with a web service. I have no control over it so I can't change the WSDL, the server, or anything of the like.
One of the data types used is xsd:dateTime, a type that according to this (Table-1, JAX-RPC supported data types), is not supported on J2ME. Based on my searches (both on this forum and on the Internet), no one uses any date/time/dateTime of any form or are told to change their WSDL so it doesn't use it if they plan on using a client on J2ME.
So does anyone have a clue on how to use it, because as I said, I have no control over the WSDL or server. Would substituting a String formatted in the appropriate manner work or would the JAX-RPC system say that it's the improper type?
I used wscompile to get the static stubs for the service, I can't compile without figuring this out (Type only has primitive types, "UNKNOWN" which is what wscompile replaces unsupported types isn't cutting it for the obvious reasons). Temporarily I replaced "UNKNOWN" with Type.STRING but I don't know if that will work (which is why I asked).
Solved! Go to Solution.
06-08-2011 11:48 AM
06-08-2011
12:38 PM
- last edited on
06-08-2011
12:59 PM
by
Chronos
I only can give you my opinion. I can't remember how many projects in my job resulted a hell, just because the WS developer company didn't comply with that table and WSDLs were complete <Inappropriate Word removed>.
When we asked them to change it, they didn't know how to solve this because the WSDL is magically generated with a framework/tool they don't understand. LOL
I think the only thing you could do is to download the WSDL, edit it, and then regenerating stubs for that local copy.
Good luck!
[Edited - Inappropriate Content. Please read your messages]
06-08-2011 12:58 PM
I actually got it to work by using Type.STRING. I wrote a small converter to convert from a Calendar to a SOAP-style dateTime string. I don't have to convert back so that isn't an issue.
While you're here though, what about base64Binary. Would that be considered a complex type because, just like with dateTime, there is no Type that corresponds to it. It's a byte[], but I can't find anything (again!) that has an example of it.
06-08-2011 10:51 PM - edited 06-08-2011 10:52 PM
Ok, the base64Binary Type I used was Type.STRING. Then I just ran it through the Base64InputStream.decode which got the job done. I realized that a couple of the types just do not work (wscompile is good for a general idea of how a web service should be implemented but horrible at the actual implementation) so I need to rewrite a good chunk of code and decided to just rewrite all of it so it works better and is cleaner.
Thanks for the help.
EDIT:
Also this was the helper function I used to convert a Calendar to a String so it would work with the web service:
public static String toSOAPString(Calendar cal)
{
if(cal == null)
{
return null;
}
StringBuffer buf = new StringBuffer();
//Get format
new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.' SSS").format(cal, buf, null);
buf.append("0000");
//Timezone
String zoneID = cal.getTimeZone().getID();
int index = zoneID.indexOf('-');
if(index == -1)
{
index = zoneID.indexOf('+');
/* If no timezone offset exists, it isn't needed
if(index == -1)
{
buf.append("+00:00");
}
*/
}
if(index != -1)
{
buf.append(zoneID.substring(index + 1));
}
return buf.toString();
}