java - Spring Webservice - 直接在 SOAP 消息体上发送属性而不被包装在类上
问题描述
我想知道是否有人可以帮助我。
我必须用这种结构调用一个 SOAP 端点:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ese="http://tsp-gate.globaltrustedsign.com/ESealPdf">
<soapenv:Header/>
<soapenv:Body>
<ese:Digest>YYYYYY</ese:Digest>
<ese:Certificate>xxxxx</ese:Certificate>
</soapenv:Body>
</soapenv:Envelope>
就像您可以看到字段直接位于 SOAP 主体的根部一样。
我正在使用 Spring WebserviceTemplate 发出请求。我也在生成基于 WSDL 的类,但它只是生成这个:
@XmlRegistry
public class ObjectFactory {
private final static QName _Digest_QNAME = new QName("http://tsp-gate.globaltrustedsign.com/ESealPdf", "Digest");
private final static QName _Certificate_QNAME = new QName("http://tsp-gate.globaltrustedsign.com/ESealPdf", "Certificate");
private final static QName _Signature_QNAME = new QName("http://tsp-gate.globaltrustedsign.com/ESealPdf", "Signature");
public ObjectFactory() {
}
@XmlElementDecl(namespace = "http://tsp-gate.globaltrustedsign.com/ESealPdf", name = "Digest")
public JAXBElement<String> createDigest(String value) {
return new JAXBElement<String>(_Digest_QNAME, String.class, null, value);
}
@XmlElementDecl(namespace = "http://tsp-gate.globaltrustedsign.com/ESealPdf", name = "Certificate")
public JAXBElement<String> createCertificate(String value) {
return new JAXBElement<String>(_Certificate_QNAME, String.class, null, value);
}
@XmlElementDecl(namespace = "http://tsp-gate.globaltrustedsign.com/ESealPdf", name = "Signature")
public JAXBElement<String> createSignature(String value) {
return new JAXBElement<String>(_Signature_QNAME, String.class, null, value);
}
}
现在,我不知道如何基于此构建请求,在某种程度上我可以使用方法 webServiceTemplate.marshalSendAndReceive()。
我还想了解 webserviceTemplate + JaxbMarshaller 是否只允许或限制创建包装在对象实例中的 XML 请求(用 @XmlRootElement 注释)。
解决方案
推荐阅读
- json - DynamoDB JSON 响应解析垂直打印
- r - 如何删除 R 中的 na 并使低于值上升
- c# - 如何设置条件 C# if 语句和 LINQ where 语句?
- ruby-on-rails - 如何降级gemfile中的gem?
- javascript - Mongoose:$lookup 后的 $project 不显示字段
- reason - ReasonReact 减速器中的动作类型错误
- android - 在 android 的 okhttp 请求中使用证书
- javascript - 浏览器 JavaScript 内存泄漏
- typescript - 打字稿提取并创建联合作为联合的子集
- sql - SQL 脚本 - 查找最近的金额和总计