Java 尝试生成JAX-WS响应并获取异常
我正在尝试生成JAX-WS响应并获得以下异常:Java 尝试生成JAX-WS响应并获取异常,java,soap,Java,Soap,我正在尝试生成JAX-WS响应并获得以下异常: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> Could not generate the XML stream caused by: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "tns"
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
Could not generate the XML stream caused by: com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "tns"
. at [row,col {unknown-source}]: [20,26].</faultstring></soap:Fault>
</return>
</soap:Body></soap:Envelope>
无法生成XML流,原因是:com.ctc.wstx.exc.WstxParsingException:未声明的命名空间前缀“tns”和#xd;。在[row,col{unknown source}]:[20,26]。
以下是我的模式:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://url"
xmlns:tns="http://url">
<xs:element name="context" nillable="true" type="tns:context" />
<xs:complexType name="context">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="Recommendations" type="tns:ArrayOfElements" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="ArrayOfElements">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Recommendation" nillable="true" type="tns:Recommendation" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Recommendation">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="item" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:element name="Recommendation" nillable="true" type="tns:Recommendation" />
<xs:element name="ArrayOfRecommendation" nillable="true" type="tns:ArrayOfRecommendation" />
</xs:schema>
有什么建议这个错误的原因是什么?我正在为这个JAX-WS使用JBoss6.2
PS.添加ArrayOfre推荐:
<xs:complexType name="ArrayOfRecommendation">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Recommendation" nillable="true" type="tns:Recommendation" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Recommendation">
<xs:sequence>
xml架构上面没有元素ArrayOfRecommension的定义。请大家也分享一下。您可能想使用ArrayOfelments而不是ArrayOfRecommension?添加了ArrayOfRecommension。这个模式是自动生成的,所以我看到的唯一问题是在名称空间中,我无法解决这个问题。Plz共享您的WSDL文件。事实证明,为请求提供服务的应用服务器JBoss没有正确处理ns,在本例中,ns:tns在内部转换为ns:a,从该模式中抛出内部类型。