java如何获取wsdl文件,如何使用Java获取WSDL文件中的复杂类型?

我已经阅读过类似的主题和示例,但是我仍然有一些关于从WSDL获取复杂类型的WSDL模式内容的问题。

我正在使用WSDL4J,Castor和JDOM库。

org.exolab.castor.xml.schema.Schema castorSchema = null ;

if(theWSDL.getTypes() !=null && theWSDL.getTypes().getExtensibilityElements() !=null){

for (Object e : theWSDL.getTypes().getExtensibilityElements()) {

schema = (Schema)e;

}

}

if (schema != null) {

DOMBuilder domBuilder = new DOMBuilder();

Element jdomSchemaElement = domBuilder.build(schema.getElement());

XMLOutputter outputter = new XMLOutputter();

String xmlout = outputter.outputString(jdomSchemaElement.getDocument());

StringReader in2 = new StringReader(xmlout);

InputSource schemaSource = new InputSource(in2);

SchemaReader schemaReader;

try {

schemaReader = new SchemaReader(schemaSource);

castorSchema= schemaReader.read();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}此代码适用于某些WSDL文件,但对于某些WSDL文件,我收到了“castorSchema = schemaReader.read();”这行错误:

Exception in thread "main" java.lang.IllegalArgumentException: getComplexType: Namespace prefix not recognized 'tns:cEstado'

at org.exolab.castor.xml.schema.Schema.getComplexType(Schema.java:951)

at org.exolab.castor.xml.schema.TypeReference.resolveTypeReference(TypeReference.java:122)

at org.exolab.castor.xml.schema.TypeReference.getType(TypeReference.java:71)

at org.exolab.castor.xml.schema.ElementDecl.getType(ElementDecl.java:349)

at org.exolab.castor.xml.schema.ElementDecl.validate(ElementDecl.java:809)

at org.exolab.castor.xml.schema.Group.validate(Group.java:463)

at org.exolab.castor.xml.schema.ComplexType.validate(ComplexType.java:815)

at org.exolab.castor.xml.schema.Schema.validate(Schema.java:2206)

at org.exolab.castor.xml.schema.reader.SchemaReader.read(SchemaReader.java:261)

at network.WSNetwork.execute(WSNetwork.java:105)

at network.WSNetwork.main(WSNetwork.java:61)

有关模式中复杂类型的wsdl文件部分:

任何帮助将不胜感激..

谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值