1
votes

I am trying to create a java call out function in OSB(version 11.1.3) to decode the URL. I can use java.net.URLDecoder.decode(data, "UTF-8"); in the program, but OSB function gives below error(When input and return type are String)

<Jun 11, 2014 7:43:30 AM UTC> <Error> <OSB Transform> <BEA-382516> <Failed to evaluate expression for callout to java method "public static java.lang.String com.help.sachinProject.ttttt.test(java.lang.String)". Argument index: 1, exception: Value of type 'org.apache.xmlbeans.impl.values.XmlAnyTypeImpl' cannot be type-cast to 'java.lang.String'>
<Jun 11, 2014 7:43:35 AM UTC> <Warning> <Socket> <BEA-000449> <Closing socket as no data read from it on 10.232.24.59:49,359 during the configured idle timeout of 5 secs>

So I should both input and return type as XmlAnyTypeImpl . How do I convert String to XmlAnyTypeImpl (XmlAnyTypeImpl available in xmlbeans.jar) ?

Here is my new program

import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
public class XMLFormatDecode {

XMLFormatDecode(){
super();
}

   public static String getValue(XmlAnyTypeImpl data)    
       {
       String decoded = java.net.URLDecoder.decode(data.toString(), "UTF-8");
       return decoded;                                         
       }


public static void main(String[] args) throws UnsupportedEncodingException {
new XMLFormatDecode();
System.out.println("Result main - "+XMLFormatDecode.getValue(null));
       }
}

will XmlAnyTypeImpl.toString() works ?

Can someone help me to convert String to XmlAnyTypeImpl ?

1

1 Answers

2
votes

The error is occurring because it can't pass XmlAnyType TO your static java method. You aren't specifying what you pass to the Java method, so I can only assume you aren't casting it properly to the right type. It gets an XmlAnyTypeImpl which needs to be converted to something else (String, int, boolean, etc.). You can probably just tweak what you're passing to the Java callout using some form of the XS Constructors:

XS Constructors

Java Callout