我想使用 jaxb 使用肥皂服务。jaxb 生成的请求是
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:Add xmlns:ns2="http://tempuri.org/">
<ns2:intA>10</ns2:intA><ns2:intB>20</ns2:intB>
</ns2:Add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)
但是响应是标题中所述的soap异常。
Caused by: org.springframework.ws.soap.client.SoapFaultClientException: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: .
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
Run Code Online (Sandbox Code Playgroud)
下面是我的肥皂配置代码。源码示例:https : //howtodoinjava.com/spring-boot/spring-soap-client-webservicetemplate/
public class ConsumeSoapApplication {
public static String wsdlurl = "http://www.dneonline.com/calculator.asmx?wsdl";
public static void main(String[] args) {
try {
JAXBContext.newInstance(com.dxc.service.soap.service.calc.ObjectFactory.class.getPackage().getName(),
com.dxc.service.soap.service.calc.ObjectFactory.class.getClassLoader());
} catch (JAXBException e) {
// TODO Auto-generated catch block …Run Code Online (Sandbox Code Playgroud) 我想解组具有混合内容的 XML 文件。我在 stackoverflow 上发现了一个似乎合适的线程(用于读取 @XmlValue 和 @XmlElement 的 JAXB- @XmlMixed 用法),其中用户 bdoughan 定义了 3 个用例来处理混合内容。
第三个用例将标签之间的文本保留在单个字符串变量中,并将元素保存在列表中。这就是我想要的。不幸的是,我无法让它工作,而且该线程很旧,可能已经过时了。
我已经尝试了用例#3 和对象列表以及我的参考类列表。我还尝试了@XmlElement 和@XmlValue 注释。
我在 Java SE 版本 12.0.2 的 Maven Projec 中使用版本 2.3.1 中的 javax.xml.bind jaxb-api 和版本 2.3.1 中的 org.glassfish.jaxb jaxb-runtime。
我测试过的示例 XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Date>
2018.06.27
<reference id="AnyId1">
</reference>
</Date>
Run Code Online (Sandbox Code Playgroud)
我的班级代表
@XmlRootElement(name="Date")
public class TestPojo {
@XmlMixed
public String getTextContent() {
return textContent;
}
public void setTextContent(String textContent) {
this.textContent = textContent;
}
@XmlElementRef(name="reference", type = Reference.class) …Run Code Online (Sandbox Code Playgroud) 我必须将大量数据编组为 XML 格式。我正在研究 JAXB,因为它是 JDK 8 的一部分,但我不确定它如何处理大量数据。Jackson XML 是我遇到的另一个更新的库。Jackson 在将对象序列化为 XML 方面是否比 JAXB 更快?
问题:无法使用 java xjc 从 cXML.dtd 创建 java 类
我使用的版本是1.2.032
使用的命令:xjc -dtd cXML.dtd
错误:正在解析架构...[错误]属性“名称”已定义。使用 <jaxb:property> 解决冲突。
问题 1:第 573 号问题附近的行号将“名称”作为其重复项(元素和属性)。
问题 2:ShippingPaymentMethod、TermsOfDeliveryCode、TransportTerms 使用“值”,导致重复定义。
据我了解解决方案==
我需要自定义绑定.xml ..我尝试了各种方法,但无法创建正确的绑定.xml 来解决此问题。一旦我有了正确的 xml,我就可以使用以下命令来创建生成的类。xjc -b 绑定.xml -dtd cXML.dtd
我需要什么帮助
请建议。
我对冬眠很陌生。我试图用 hibernate 制作我的第一个应用程序,但遇到了下一个异常:
线程“main”java.lang 中的异常。
NoClassDefFoundError: javax/xml/bind/JAXBException at org.hibernate.boot.cfgxml.internal.ConfigLoader$1.initialize(ConfigLoader.java:41) at org.hibernate.boot.cfgxml.internal.ConfigLoader$1.initialize(ConfigLoader.java:38) ) 在 org.hibernate.internal.util.ValueHolder.getValue(ValueHolder.java:55) 在 org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57) 在 org.hibernate.boot.registry。 StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:163) at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:152) at Main.main(Main.java:19) 由:java.lang.ClassNotFoundException: javax .xml.bind.JAXBException at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) at java.base/jdk。internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185) 在 java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ... 7 更多
我的 pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>app</groupId>
<artifactId>qapp</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.2.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
主要方法
public static void main(String[] args){ …Run Code Online (Sandbox Code Playgroud)