- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试为工作应用程序(spring、hibernate、soap、cxf)实现集成测试。我手动构建 SOAP-XML 并将其处理到我的端点。像这样:
private Source createRequest(String domainName, String email, String userId, String password) {
String content = "";
content += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:sup=\"[...]">";
content += " <soapenv:Header/>";
content += " <soapenv:Body>";
content += " <sup:RegisterRequest>";
content += " <sup:domain>" + domainName + "</sup:domain>";
content += " <sup:email>" + email + "</sup:email>";
content += " <sup:userId>" + userId + "</sup:userId>";
content += " <sup:password>" + password + "</sup:password>";
content += " </sup:RegisterRequest>";
content += " </soapenv:Body>";
content += "</soapenv:Envelope>";
return new StringSource(content);
}
在我的测试中,我将其处理到我的端点,如下所示:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "../../WEB-INF/applicationContext.xml", "../../WEB-INF/test.xml" })
@Transactional
public class TestRegisterEndpoint extends AbstractTransactionalJUnit4SpringContextTests {
@Resource
private RegisterEndpoint registerEndpoint;
@Test
public void registerUserFailsForUnexistantDomain() throws Exception {
Source result = registerEndpoint.invoke(createRequest("unexistant_domain", "test@test.de", "test@test.de", "myPassword1"));
}
}
但是当我尝试运行测试时,出现异常“找不到元素“soapenv:Envelope”的声明。”。
org.springframework.oxm.jaxb.JaxbUnmarshallingFailureException: JAXB unmarshalling exception: null; nested exception is javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'soapenv:Envelope'.]
at org.springframework.oxm.jaxb.JaxbUtils.convertJaxbException(JaxbUtils.java:75)
[...]
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'soapenv:Envelope'.]
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315)
[...]
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'soapenv:Envelope'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
我想我必须在我没有的地方定义“soapenv”命名空间。但如果是这样,我不知道在哪里。
“applicationContext.xml”的开始:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
“test.xml”的开始:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
如何消除异常?
最佳答案
好的,我在其他地方找到了帮助。解决方案:因为我的端点扩展了“PayloadEndpoint”
public interface RegisterEndpoint extends PayloadEndpoint {
}
我必须仅将有效负载插入端点(听起来合乎逻辑;))。如果我这样做:
private Source createRequest(String domainName, String email, String userId, String password) {
String content = "";
content += "<sup:RegisterRequest xmlns:sup=\"[...]\">";
content += " <sup:domain>" + domainName + "</sup:domain>";
content += " <sup:email>" + email + "</sup:email>";
content += " <sup:userId>" + userId + "</sup:userId>";
content += " <sup:password>" + password + "</sup:password>";
content += "</sup:PreregisterRequest>";
return new StringSource(content);
}
一切正常。
关于spring - 通过 junit 测试 SOAP 端点会抛出 SAXParseException (soapenv :Envelope),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1687762/
我的applicationContext.xml文件有问题。 classpath:configuration.properties
我对 JAXB 很陌生。我的经验非常好,但现在我在解码时遇到了一些问题。 我的类实现了以下接口(interface): public interface Attribute { public
我有一个服务可以解析 XML 并使用 exception.getMessage() (exception.getLocalizedMessage()) 生成包含解析器错误列表的报告(完全是 SAXPa
我编写了一个程序来读取一组源文件并使用 SrcML 工具将它们转换为 XML 文件。基本上流程如下。 for (------------------) { ------------------
原因:org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:发现以元素“jr:table”开头的无效内容。需要 '{"http://jasperre
我在 Windows 10 上运行的 Java 1.8.0_191 程序中收到以下 UnmarshalException,该程序使用 jaxb2 Maven 插件版本 2.5.0 生成的类来处理传入的
您好,我正在使用 jena 读取 som rdf 文件: InputStream in = FileManager.get().open(adress); model.read(in,
在 hibernate.hbm.xml 文件中使用属性 version 和 timestamp 并运行程序时,出现异常。如果删除 version 属性,程序可以正常工作,但使用两者时会出现运行时错误。
我正在尝试使用 Spring Boot 开发一个应用程序,我有以下 html Hello AngularJS The ID is {{greeting.id}} The content
File xml = new File("C:/members.xml"); DocumentBuilderFactory documentBuilderFactory = Docum
我在一个 Maven 项目中工作。 Atm 我只有实体、映射和配置文件。我正在尝试使用 junit 测试我的 hibernate 映射。 我找不到问题。我可以在 netbeans 中验证 xml 文件
这是我的 Coldfusion Web 服务。当我使用soapUI工具调用'test'时,我收到了这个 "org.xml.sax.SAXParseException: Premature end of
我们有一个使用不同产品口味和产品类型的项目。当我选择特定口味时,会生成此错误: FAILURE: Build failed with an exception. * What went wrong:
可能相关: Grails - attempting to include HTPPBuilder - Linkage error 我正在尝试将XOM包含在我的grails项目中。我如何知道需要排除哪个
我正在尝试使用 DocumentBuilder 的 parse 方法解析 xml,该方法将 URI 作为参数。为此,我创建一个表示 URI 的 String 对象,然后调用 parse 方法,将 St
运行 xml-rcp 服务器和客户端。尝试将请求记录到服务器。但出现文件过早结束错误。谁能看出我做错了什么吗? public void doPost(HttpServletRequest req,
我正在尝试在 Mac OS X 10.10 中运行基本的 Jetty 应用程序。我正在关注这个例子 - http://www.codeproject.com/Articles/128145/Run-J
我正在关注“Professional Android Application Development”一书并尝试实现一些示例。在第 5 章第 151 页中,以下代码引发 SAXParseExcepti
所以我知道使用这个API,我在服务器上生成的一些xml文件可能会错误地生成,或者没有关闭一些标签,或者结构很糟糕。现在我的代码工作正常,但对于某些文件,其中一些 xml 文件会抛出这些错误,下面是错误
我正在使用 Play Framework 1.2.4 并尝试解析 SOAP 响应。 响应是: ... 当我尝试使用 play.libs.WS.HttpResponse.getXml() 解析
我是一名优秀的程序员,十分优秀!