Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ApacheCamelJava和XPath_Java_Xpath_Apache Camel - Fatal编程技术网

ApacheCamelJava和XPath

ApacheCamelJava和XPath,java,xpath,apache-camel,Java,Xpath,Apache Camel,因此,我有一个具有多个名称空间的web服务,我希望通过bean路由这些名称空间来检查用户凭据。我已经很久没有使用XPATH了,所以我可能只是有一个野餐(在椅子上的问题不是在计算机时刻)错误 web服务消息将始终具有以下结构/模式: <Operation> <header with the head name space where the user credentials are stored> <record control> <

因此,我有一个具有多个名称空间的web服务,我希望通过bean路由这些名称空间来检查用户凭据。我已经很久没有使用XPATH了,所以我可能只是有一个野餐(在椅子上的问题不是在计算机时刻)错误

web服务消息将始终具有以下结构/模式:

<Operation>
    <header with the head name space where the user credentials are stored>
    <record control>
    <objXX>
</Operation>
但是,当我通过soap UI发送请求时,会出现以下异常:

Invalid xpath: //head:MsgGUID. Reason: javax.xml.xpath.XPathExpressionException: net.sf.saxon.trans.XPathException: Prefix head has not been declared
那么我该如何检索这些信息呢?为什么即使我在camel-context.xml中声明了名称空间,它们也会被报告为丢失

出于兴趣,我尝试了XPATH的几种变体,例如:

@XPath("//MsgGUID")
@XPath("//MsgReqHdr/head:MsgGUID")
@XPath("//head:MsgReqHdr/head:MsgGUID")

每次我得到上面列出的异常或空值时

是的,它开始工作了。在处理bean中的名称空间时,必须使用以下语法来包含名称空间

public class IRIXSecurity {



    public void CheckCredentials(
            //@Body ListDebtorReqType msgBody, @Headers Map hdr,

            @XPath(value="//header:MsgGUID",namespaces = @NamespacePrefix(
                    prefix = "header",
                    uri = "http://www.insol.irix.com.au/IRIX_V1/Headers")) String msgGUID,
            @Body Document xml)
    {


        System.out.println("Check Credentials Invoked");
        System.out.println(msgGUID);
        //exchange.getOut().setBody(debtorRsType);





    }
}
Invalid xpath: //head:MsgGUID. Reason: javax.xml.xpath.XPathExpressionException: net.sf.saxon.trans.XPathException: Prefix head has not been declared
@XPath("//MsgGUID")
@XPath("//MsgReqHdr/head:MsgGUID")
@XPath("//head:MsgReqHdr/head:MsgGUID")
public class IRIXSecurity {



    public void CheckCredentials(
            //@Body ListDebtorReqType msgBody, @Headers Map hdr,

            @XPath(value="//header:MsgGUID",namespaces = @NamespacePrefix(
                    prefix = "header",
                    uri = "http://www.insol.irix.com.au/IRIX_V1/Headers")) String msgGUID,
            @Body Document xml)
    {


        System.out.println("Check Credentials Invoked");
        System.out.println(msgGUID);
        //exchange.getOut().setBody(debtorRsType);





    }
}