【问题标题】:OSB java callout function - Cast XmlAnyTypeImpl to StringOSB java 标注函数 - 将 XmlAnyTypeImpl 转换为字符串
【发布时间】:2014-08-03 17:24:53
【问题描述】:

我正在尝试在 OSB(版本 11.1.3)中创建一个 java 调用函数来解码 URL。我可以在程序中使用java.net.URLDecoder.decode(data, "UTF-8");,但是OSB函数给出以下错误(当输入和返回类型为字符串时)

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

所以我应该输入和返回类型为 XmlAnyTypeImpl 。如何将 String 转换为 XmlAnyTypeImpl (XmlAnyTypeImpl 在 xmlbeans.jar 中可用)

这是我的新程序

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

XmlAnyTypeImpl.toString() 会起作用吗?

有人可以帮我将 String 转换为 XmlAnyTypeImpl 吗?

【问题讨论】:

    标签: java jakarta-ee oracle11g osb oracle-fusion-middleware


    【解决方案1】:

    发生错误是因为它无法将XmlAnyType TO 传递给您的静态 java 方法。您没有指定传递给 Java 方法的内容,所以我只能假设您没有正确地将其转换为正确的类型。它得到一个XmlAnyTypeImpl,需要将其转换为其他内容(字符串、整数、布尔值等)。您可能只需使用某种形式的 XS 构造函数来调整您传递给 Java 标注的内容:

    【讨论】:

    • 你能看看错误吗?这发生在我传递字符串并返回字符串时。
    • 我们在 OSB 控制台中使用了 XS 构造函数,但仍然出现同样的错误。
    • 现在得到
    • 如果您查看the docs,Java 方法只能是类型的一小部分,XmlAnyTypeImpl 不是其中之一。回到我原来的答案,您实际上是从节点(例如$body/node/node/text())中获取 text(),还是只是盲目地将 xs:string() 传递给某个节点,希望它能够将您的东西转换成正确的东西?
    • 亲爱的尼克,在 OSB 中,我们应该将 URL 传递给出站,但是 URL 是用 java.net.Encode 编码的,所以我尝试使用 java.net.Decode 和 java callout 进行解码.所以我用输入和返回类型r字符串创建了一个pgm然后得到了错误(在queston-line 4中提到)。通过查看错误我知道输入应该是XmlAnyTypeImpl的格式。所以我的程序改变了(问题中提到)使用 XmlAnyTypeImpl 输入。现在我得到“com.bea.wli.sb.context.impl.EndpointTypeImpl' 类型的值不能类型转换为 .XmlAnyTypeImpl'”。Pasing URL 希望它用方法转换跨度>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-17
    • 1970-01-01
    • 2018-11-24
    • 1970-01-01
    相关资源
    最近更新 更多