我试图读取SOAP响应(内容类型multipart / mixed.Mime头文件:application / soap + xml) 这适用于Java 1.6和Weblogic 11g,但不适用于Java 1.7 / Weblogic 12c。抛出异常的extractContentAsDocument()来自:jar:file:/u01/app/oracle/Middleware/12c/oracle_common/modules/com.oracle.webservices.orasaaj-rt-api_12.1.2.jar!/ oracle / J2EE / WS / SAAJ /肥皂/ SOAP12 / Body12.class
错误:
javax.xml.soap.SOAPException:如果存在多个子元素,则无法提取SOAPBody内容 at oracle.j2ee.ws.saaj.soap.BodyImpl.extractContentAsDocument(BodyImpl.java:233) 在queryProducer(queryProducer.java:84)
queryProducer.java:83:
SOAPMessage response = dispatch.invoke(request);
return response.getSOAPBody().extractContentAsDocument();
完整回复(作为字符串):
金塔:IHE:ITI:2007:CrossGatewayQueryResponse f3116ff8-378d-11e4-b68e-8f828f8a95e9 金塔:IHE:ITI:2007:CrossGatewayQuery
<AdhocQueryResponse xmlns="urn:mynamespace" status="urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success">
...
Maven依赖树:
[INFO] mypackage.myapp:myapp_wrap_haims_query:war:4.4.1.158-SNAPSHOT
[INFO] +- mypackage.integration:integration-bpm:jar:4.4.1.158-SNAPSHOT:compile
[INFO] | +- mypackage.integration:integration-http:jar:4.4.1.158-SNAPSHOT:compile
[INFO] | | \- org.apache.cxf:cxf-rt-frontend-jaxrs:jar:2.7.7:compile
[INFO] | | +- org.apache.cxf:cxf-api:jar:2.7.7:compile
[INFO] | | | +- org.codehaus.woodstox:woodstox-core-asl:jar:4.2.0:compile
[INFO] | | | | \- org.codehaus.woodstox:stax2-api:jar:3.1.1:compile
[INFO] | | | +- org.apache.ws.xmlschema:xmlschema-core:jar:2.0.3:compile
[INFO] | | | \- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.7.1:compile
[INFO] | | +- org.apache.cxf:cxf-rt-core:jar:2.7.7:compile
[INFO] | | +- javax.ws.rs:javax.ws.rs-api:jar:2.0-m10:compile
[INFO] | | +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.7.7:compile
[INFO] | | \- org.apache.cxf:cxf-rt-transports-http:jar:2.7.7:compile
[INFO] | +- xalan:xalan:jar:2.7.1:compile
[INFO] | | \- xalan:serializer:jar:2.7.1:compile
[INFO] | +- xerces:xercesImpl:jar:2.9.0:provided
[INFO] | +- org.hibernate:hibernate-core:jar:3.6.10.Final:compile
[INFO] | | +- antlr:antlr:jar:2.7.6:compile
[INFO] | | +- commons-collections:commons-collections:jar:3.1:compile
[INFO] | | +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] | | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
[INFO] | | \- javax.transaction:jta:jar:1.1:compile
[INFO] | +- org.hibernate:hibernate-entitymanager:jar:3.6.10.Final:compile
[INFO] | | \- javassist:javassist:jar:3.12.0.GA:compile
[INFO] | \- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] +- mypackage.integration:integration-core:jar:4.4.1.158-SNAPSHOT:compile
[INFO] | +- org.springframework:spring-web:jar:3.0.5.RELEASE:compile
[INFO] | +- org.safehaus.jug:jug:jar:asl:2.0.0:compile
[INFO] | +- net.sf.dozer:dozer:jar:5.3.2:compile
[INFO] | | +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] | | \- commons-lang:commons-lang:jar:2.5:compile
[INFO] | +- net.sf.json-lib:json-lib:jar:jdk15:2.3:compile
[INFO] | | \- net.sf.ezmorph:ezmorph:jar:1.0.6:compile
[INFO] | +- xom:xom:jar:1.1:compile
[INFO] | | +- xerces:xmlParserAPIs:jar:2.6.2:provided
[INFO] | | \- jaxen:jaxen:jar:1.1.1:compile
[INFO] | +- org.aspectj:aspectjtools:jar:1.5.4:compile
[INFO] | +- cglib:cglib:jar:2.2.2:compile
[INFO] | +- gov.hhs.healthit.nhin.connect:common-types:jar:2.4:compile
[INFO] | +- commons-codec:commons-codec:jar:1.6:compile
[INFO] | +- commons-io:commons-io:jar:2.0.1:compile
[INFO] | \- com.sun.xml.messaging.saaj:saaj-impl:jar:1.3.19:compile
[INFO] | \- org.jvnet.mimepull:mimepull:jar:1.7:compile
[INFO] +- mypackage.integration:integration-test:jar:4.4.1.158-SNAPSHOT:compile
[INFO] | +- xmlunit:xmlunit:jar:1.3:test
[INFO] | \- eviware:maven-soapui-plugin:jar:4.5.1:test
[INFO] | +- org.apache.maven:maven-plugin-api:jar:2.0:test
[INFO] | +- eviware:soapui:jar:4.5.1:test
[INFO] | +- javax.activation:activation:jar:1.1:compile
[INFO] | +- javax.mail:mail:jar:1.4:compile
[INFO] | +- wsdl4j:wsdl4j:jar:1.6.2-fixed:compile
[INFO] | +- commons-ssl:not-yet-commons-ssl:jar:0.3.11:test
[INFO] | +- commons-cli:commons-cli:jar:1.0:test
[INFO] | +- json:json-lib:jar:2.2.2-jdk15:test
[INFO] | +- ezmorph:ezmorph:jar:1.0.5:test
[INFO] | +- swingx:swingx:jar:soapui:test
[INFO] | +- groovy:groovy-all:jar:1.8.0:test
[INFO] | +- rhino:js:jar:1.7R2:test
[INFO] | +- jetty:jetty:jar:6.1.26:test
[INFO] | +- jetty:jetty-util:jar:6.1.26:test
[INFO] | +- jetty:servlet-api:jar:2.5-20081211:test
[INFO] | +- net-components:netcomponents:jar:1.3.8a:test
[INFO] | +- xmlbeans:xbean:jar:fixed-2.4.0:test
[INFO] | +- xmlbeans:xbean_xpath:jar:2.4.0:test
[INFO] | +- xmlbeans:xmlpublic:jar:2.4.0:test
[INFO] | +- xmlbeans:jsr173:jar:xmlbeans-2.4.0:test
[INFO] | +- eviware:soapui-xmlbeans:jar:4.5.1:test
[INFO] | +- eviware:policy-xmlbeans:jar:1.5:test
[INFO] | +- eviware:soap-xmlbeans:jar:1.2:test
[INFO] | +- eviware:wadl-xmlbeans:jar:1.1:test
[INFO] | +- eviware:j2ee-xmlbeans:jar:1.4:test
[INFO] | +- eviware:ext-xmlbeans:jar:1.2:test
[INFO] | +- saxon:saxon:jar:9.1.0.8j:test
[INFO] | +- saxon:saxon-dom:jar:9.1.0.8j:test
[INFO] | +- xml-security:xmlsec:jar:1.4.3:test
[INFO] | +- opensaml:opensaml:jar:1.1:test
[INFO] | +- wss4j:wss4j:jar:1.5.8:test
[INFO] | +- bouncycastle:bcprov-jdk15:jar:144:test
[INFO] | +- jtidy:jtidy:jar:r872-jdk15:test
[INFO] | +- javax.jms:jms:jar:1.1:test
[INFO] | +- hermesjms:hermes:jar:1.14:test
[INFO] | +- amf:flex-messaging-common:jar:1.0:test
[INFO] | +- amf:flex-messaging-core:jar:1.0:test
[INFO] | +- amf:flex-messaging-opt:jar:1.0:test
[INFO] | +- amf:flex-messaging-proxy:jar:1.0:test
[INFO] | +- amf:flex-messaging-remoting:jar:1.0:test
[INFO] | +- thoughtworks:xstream:jar:1.3.1:test
[INFO] | +- net.sourceforge.htmlunit:htmlunit:jar:2.7:test
[INFO] | | \- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] | +- org.w3c.css:sac:jar:1.3:test
[INFO] | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.7:test
[INFO] | +- net.sourceforge.cssparser:cssparser:jar:0.9.5:test
[INFO] | +- net.sourceforge.nekohtml:nekohtml:jar:1.9.14:test
[INFO] | +- fife:rsyntaxtextarea:jar:1.3.4:test
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.1.1:test
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.1.1:test
[INFO] | +- org.apache.httpcomponents:httpclient-cache:jar:4.1.1:test
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.1.1:test
[INFO] | +- org.apache.httpcomponents:httpcore-nio:jar:4.1.1:test
[INFO] | \- org.samba.jcifs:jcifs:jar:1.2.9:test
[INFO] +- mypackage.myapp:myapp_common:jar:4.4.1.158-SNAPSHOT:compile
[INFO] | +- mypackage.integration:integration-jms:jar:4.4.1.158-SNAPSHOT:compile
[INFO] | | \- ca.uhn.hapi:hapi-base:jar:0.6:compile
[INFO] | \- mypackage.integration:integration-feed:jar:4.4.1.158-SNAPSHOT:compile
[INFO] +- mypackage.myapp:myapp_mock:jar:4.4.1.158-SNAPSHOT:compile
[INFO] | +- mypackage.integration:integration-hl7:jar:4.4.1.158-SNAPSHOT:compile
[INFO] | +- mypackage.myapp:myapp_bindings:jar:4.4.1.158-SNAPSHOT:compile
[INFO] | \- mypackage.myapp:myapp_audit:jar:4.4.1.158-SNAPSHOT:compile
[INFO] +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-jdbc:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-jms:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-core:jar:3.1.0.RC2:compile
[INFO] +- org.springframework.ws:spring-ws:jar:2.0.0-M1:compile
[INFO] +- org.springframework:spring-oxm:jar:3.0.5.RELEASE:compile
[INFO] +- com.sun.jersey:jersey-server:jar:1.8:compile
[INFO] | +- asm:asm:jar:3.3.1:compile
[INFO] | \- com.sun.jersey:jersey-core:jar:1.8:compile
[INFO] +- com.sun.jersey:jersey-client:jar:1.8:compile
[INFO] +- com.sun.jersey:jersey-json:jar:1.8:compile
[INFO] | +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] | | \- stax:stax-api:jar:1.0.1:compile
[INFO] | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] | | \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
[INFO] | | \- javax.xml.stream:stax-api:jar:1.0-2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.7.1:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.7.1:compile
[INFO] | +- org.codehaus.jackson:jackson-jaxrs:jar:1.7.1:compile
[INFO] | \- org.codehaus.jackson:jackson-xc:jar:1.7.1:compile
[INFO] +- com.sun.jersey.contribs:jersey-atom-abdera:jar:1.8:compile
[INFO] | +- org.apache.abdera:abdera-parser:jar:1.0:compile
[INFO] | | +- org.apache.abdera:abdera-core:jar:1.0:compile
[INFO] | | | +- org.apache.abdera:abdera-i18n:jar:1.0:compile
[INFO] | | | \- org.apache.geronimo.specs:geronimo-activation_1.0.2_spec:jar:1.1:compile
[INFO] | | +- org.apache.ws.commons.axiom:axiom-impl:jar:1.2.5:compile
[INFO] | | | \- org.apache.ws.commons.axiom:axiom-api:jar:1.2.5:compile
[INFO] | | +- org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile
[INFO] | | \- org.codehaus.woodstox:wstx-asl:jar:3.2.6:runtime
[INFO] | \- org.apache.abdera:abdera-extensions-json:jar:1.0:compile
[INFO] | +- org.apache.abdera:abdera-server:jar:1.0:compile
[INFO] | | \- javax.servlet:servlet-api:jar:2.4:compile
[INFO] | +- org.apache.abdera:abdera-extensions-main:jar:1.0:compile
[INFO] | | \- org.apache.abdera:abdera-client:jar:1.0:compile
[INFO] | \- org.apache.abdera:abdera-extensions-html:jar:1.0:compile
[INFO] | \- nu.validator.htmlparser:htmlparser:jar:1.0.5:compile
[INFO] +- com.sun.jersey:jersey-atom:jar:1.8:compile
[INFO] | +- rome:rome:jar:0.9:compile
[INFO] | \- jdom:jdom:jar:1.0:compile
[INFO] +- com.sun.jersey.contribs:jersey-multipart:jar:1.8:compile
[INFO] | \- org.jvnet:mimepull:jar:1.4:compile
[INFO] +- com.sun.jersey.contribs:jersey-spring:jar:1.8:compile
[INFO] +- com.sun.jersey.contribs:jersey-guice:jar:1.8:compile
[INFO] | +- javax.inject:javax.inject:jar:1:compile
[INFO] | +- com.google.inject:guice:jar:3.0:compile
[INFO] | \- com.google.inject.extensions:guice-servlet:jar:3.0:compile
[INFO] +- net.sf.saxon:saxon:jar:9.1.0.8:compile
[INFO] +- net.sf.saxon:saxon-dom:jar:9.1.0.8:compile
[INFO] +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | \- xml-apis:xml-apis:jar:1.0.b2:provided
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] +- org.slf4j:com.springsource.slf4j.org.apache.commons.logging:jar:1.6.1:runtime
[INFO] +- org.slf4j:com.springsource.slf4j.log4j:jar:1.6.1:runtime
[INFO] +- log4j:log4j:jar:1.2.16:compile
[INFO] +- org.eclipse.jetty:jetty-server:jar:7.6.13.v20130916:test
[INFO] | +- org.eclipse.jetty.orbit:javax.servlet:jar:2.5.0.v201103041518:test
[INFO] | +- org.eclipse.jetty:jetty-continuation:jar:7.6.13.v20130916:test
[INFO] | \- org.eclipse.jetty:jetty-http:jar:7.6.13.v20130916:test
[INFO] | \- org.eclipse.jetty:jetty-io:jar:7.6.13.v20130916:test
[INFO] | \- org.eclipse.jetty:jetty-util:jar:7.6.13.v20130916:test
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] +- com.oracle:ojdbc6:jar:11.1.0.6.0:test
[INFO] \- org.springframework:spring-test:jar:3.0.5.RELEASE:test
答案 0 :(得分:0)
好的......我有完全相同的问题并解决了它。 它实际上是解决方法。 创建您的Envelope.class和Body.class,例如:
@XmlRootElement(name = "Envelope", namespace = "http://schemas.xmlsoap.org/soap/envelope/")
public class Envelope {
@XmlElement(name = "Body", namespace = "http://schemas.xmlsoap.org/soap/envelope/")
private Body body;
public Body getBody() {
return body;
}
public void setBody() {
this.body = new Body();
}
}
和
@XmlType
public class Body {
@XmlElement(name = "NameOfElementChildInBody", namespace = "namespace if needed for body")
private POJOClassOfElementChildInBody someVariableName;
public void setterIfNeeded(POJOClassOfElementChildInBody someVariableName) {
this.someVariableName = someVariableName;
}
}
并在您的代码中放置:
SOAPMessage response = dispatch.invoke(request);
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.writeTo(out);
JAXBContext jc = JAXBContext.newInstance(Envelope.class);
Unmarshaller um = jc.createUnmarshaller();
Envelope envelope = (Envelope) um.unmarshal(new ByteArrayInputStream(out.toByteArray()));
Body body = envelope.getBody();
body.methodFromWsdl... etc.
答案 1 :(得分:0)
我有相同的问题,但有相同的异常和消息。我们正在使用一种模拟服务,该服务返回罐装XML来匹配请求。问题在于SOAP Body元素的子元素周围有空格,并触发了此异常。
通常,正常的Web服务生成一行XML,使用该XML不会出现任何问题。
答案 2 :(得分:-1)
我尝试了不同的方法让它工作并使其正常工作,如下所示:java.lang.NoClassDefFoundError: org/apache/cxf/jaxrs/impl/UriBuilderImpl。我认为最重要的可能是升级Jersey的版本,而不喜欢应用程序包。