我有两个需要解析的XSD文件。加上一个带内联架构的wsdl文件。我正在使用XSOM来解析所有三个文件。 “XSD”文件被正确解析。但是,当我尝试从WSDL文件转换内联架构时,我得到以下异常。
带有内联模式文件的BPEL WSDL如下所示:`
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:plnk="http://docs.oasis- open.org/wsbpel/2.0/plnktype" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://bankloanprocess" xmlns:vprop="http://docs.oasis-open.org/wsbpel/2.0/varprop" xmlns:wsdl="http://risk/" xmlns:wsdl1="http://assess/" name="BankLoanProcess" targetNamespace="http://bankloanprocess" xmlns:p="http://www.w3.org/2001/XMLSchema">
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TYPE DEFINITION - List of types participating in this BPEL process
The BPEL Designer will generate default request and response types
but you can define or import any XML Schema type and use them as part
of the message types.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<plnk:partnerLinkType name="CalculateRiskPLT">
<plnk:role name="CalculateRiskRole" portType="wsdl:Risk"/>
</plnk:partnerLinkType>
<plnk:partnerLinkType name="AssessRiskPLT">
<plnk:role name="AssessRiskRole" portType="wsdl1:Assessment"/>
</plnk:partnerLinkType>
<import location="RiskService.wsdl" namespace="http://risk/"/>
<import location="AssessmentService.wsdl" namespace="http://assess/"/>
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://bankloanprocess">
<element name="BankLoanProcessRequest">
<complexType>
<sequence>
<element name="ClientId" type="int"/>
<element name="LoanAmount" type="double"/>
</sequence>
</complexType>
</element>
<element name="BankLoanProcessResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MESSAGE TYPE DEFINITION - Definition of the message types used as
part of the port type defintions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<message name="BankLoanProcessRequestMessage">
<part name="payload" element="tns:BankLoanProcessRequest"></part>
</message>
<message name="BankLoanProcessResponseMessage">
<part element="tns:BankLoanProcessResponse" name="payload"/>
</message>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PORT TYPE DEFINITION - A port type groups a set of operations into
a logical service unit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- portType implemented by the BankLoanProcess BPEL process -->
<message name="ApproveMessage">
<part name="Reply" type="p:string"></part>
</message>
<portType name="BankLoanProcess">
<operation name="process">
<input message="tns:BankLoanProcessRequestMessage"/>
<output message="tns:BankLoanProcessResponseMessage"/>
</operation>
</portType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PARTNER LINK TYPE DEFINITION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<plnk:partnerLinkType name="BankLoanProcess">
<plnk:role name="BankLoanProcessProvider" portType="tns:BankLoanProcess"/>
</plnk:partnerLinkType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BINDING DEFINITION - Defines the message format and protocol details
for a web service.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<binding name="BankLoanProcessBinding" type="tns:BankLoanProcess">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="process">
<soap:operation soapAction="http://bankloanprocess/process"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SERVICE DEFINITION - A service groups a set of ports into
a service unit.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<service name="BankLoanProcess">
<port binding="tns:BankLoanProcessBinding" name="BankLoanProcessPort">
<soap:address location="http://localhost:8080/ode/processes/BankLoanProcess"/>
</port>
</service>
</definitions>
`
//我正在使用此XSOM代码进行转换。我从XSOM用户指南中获取了这个
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer(new StreamSource(new File("wsdl2xsd.xsl"));
ContentHandler xsomHandler = parser.getParserHandler();
// run the transformation and feed the result to XSOM
t.transform( new StreamSource(new File("test.wsdl")),new SAXResult(xsomHandler));
XSSchemaSet sset = parser.getResult();
// The style sheet is taken from previous post. It should extract the schema information //out of the provided WSDL.
<?xml-stylesheet type="text/xsl"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s="http://www.w3.org/2001/XMLSchema" >
<xsl:output method="xml" />
<xsl:template match='text()' />
<xsl:template match="//s:schema">
<xsl:copy-of select='.'/>
</xsl:template>
</xsl:stylesheet>
` 我得到以下异常
ERROR: com.sun.org.apache.xalan.internal.xsltc.TransletException: java.lang.NullPointerException'
javax.xml.transform.TransformerException: com.sun.org.apache.xalan.internal.xsltc.TransletException: com.sun.org.apache.xalan.internal.xsltc.TransletException: java.lang.NullPointerException
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:713)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
at SchemaParser.parseSchemas(SchemaParser.java:45)
at Main.main(Main.java:79)
Caused by: com.sun.org.apache.xalan.internal.xsltc.TransletException: com.sun.org.apache.xalan.internal.xsltc.TransletException: java.lang.NullPointerException
at com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl.copy(SAXImpl.java:1678)
at com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl.copy(SAXImpl.java:1599)
at com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter.copy(DOMAdapter.java:301)
at wsdl2xsd.template$dot$1()
at wsdl2xsd.applyTemplates()
at wsdl2xsd.applyTemplates()
at wsdl2xsd.applyTemplates()
at wsdl2xsd.applyTemplates()
at wsdl2xsd.transform()
at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:603)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:709)
com.sun.org.apache.xalan.internal.xsltc.TransletException: com.sun.org.apache.xalan.internal.xsltc.TransletException: java.lang.NullPointerException
at com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl.copy(SAXImpl.java:1678)
at com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl.copy(SAXImpl.java:1599)
at com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter.copy(DOMAdapter.java:301)
at wsdl2xsd.template$dot$1()
at wsdl2xsd.applyTemplates()
at wsdl2xsd.applyTemplates()
at wsdl2xsd.applyTemplates()
at wsdl2xsd.applyTemplates()
at wsdl2xsd.transform()
at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:603)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:709)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
at SchemaParser.parseSchemas(SchemaParser.java:45)
at Main.main(Main.java:79)
可能是什么原因? 感谢您的任何建议