Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon
Accepted Solution

JAX-RPC, Webservice, and the all elusive dateTime type

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).

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: JAX-RPC, Webservice, and the all elusive dateTime type

Has anyone even come across this? Or is my sarcastic joke about no one ever using dateTime actually true?
---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 178
Registered: ‎11-19-2008
My Device: Not Specified

Re: JAX-RPC, Webservice, and the all elusive dateTime type

[ Edited ]

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]

Highlighted
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: JAX-RPC, Webservice, and the all elusive dateTime type

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.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: JAX-RPC, Webservice, and the all elusive dateTime type

[ Edited ]

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();
}

 

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.