- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我到处搜索,但找不到这个问题的答案。
我正在使用 spring-ws 创建一个可以使用 SOAP 消息的 url。我关注了Producing a SOAP web service Spring 教程。
当我向该对象发送值时,所有属性均为空。我想要消息属性的值。我似乎无法弄清楚为什么所有属性都为空。
端点如下所示:
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "UICMessage")
@ResponsePayload
public void getMessage(@RequestPayload JAXBElement<UICMessage> request) {
System.out.println(request.getValue());
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(UICMessage.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.setProperty("com.sun.xml.bind.characterEscapeHandler", (CharacterEscapeHandler) (ch, start, length, isAttVal, out) -> out.write(ch, start, length));
StringWriter sw = new StringWriter();
jaxbMarshaller.marshal(request, sw);
String xmlString = sw.toString();
System.out.println(xmlString);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
UICMessage uicMessage = (UICMessage) unmarshaller.unmarshal(new StringSource(xmlString));
System.out.println(uicMessage.getMessage());
} catch (JAXBException e) {
e.printStackTrace();
}
}
我在 POST 请求中发送到上面/ws/ci 端点的 SOAP 消息
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:head="http://uic.cc.org/UICMessage/Header" xmlns:uic="http://uic.cc.org/UICMessage">
<soapenv:Header>
<head:signed>false</head:signed>
<head:encrypted>false</head:encrypted>
<head:compressed>false</head:compressed>
<head:messageIdentifier>xxx</head:messageIdentifier>
</soapenv:Header>
<soapenv:Body>
<uic:UICMessage>
<message>
<TrainCompositionMessage xmlns="http://taf-jsg.info/schemes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">XMLVALUE</TrainCompositionMessage>
</message>
<senderAlias>USER</senderAlias>
</uic:UICMessage>
</soapenv:Body>
</soapenv:Envelope>
我从端点获取的控制台日志。
首先,我尝试立即记录属性。所有属性均为空。接下来,我尝试再次将它们编码为字符串,属性是可见且良好的。
接下来,我尝试再次对它们进行解码,所有属性再次为空。
UICMessage{message=[message: null], signature=null, senderAlias=[senderAlias: null], encoding=null}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:UICMessage xmlns:ns2="http://uic.cc.org/UICMessage">
<message xmlns:head="http://uic.cc.org/UICMessage/Header" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:uic="http://uic.cc.org/UICMessage">
<TrainCompositionMessage xmlns="http://taf-jsg.info/schemes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">XMLVALUE</TrainCompositionMessage>
</message>
<senderAlias xmlns:head="http://uic.cc.org/UICMessage/Header" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:uic="http://uic.cc.org/UICMessage">USER</senderAlias>
</ns2:UICMessage>
[message: null]
我使用的 wsdl 看起来像这样:
<wsdl:definitions xmlns:ns1="http://uic.cc.org/UICMessage/Header" xmlns:ns2="http://schemas.xmlsoap.org/soap/http"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://uic.cc.org/UICMessage"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="LIReceiveMessageService" targetNamespace="http://uic.cc.org/UICMessage">
<wsdl:documentation>
This WSDL describes the communication protocol for sending TAF/TAP -TSI messages with standard xml Header node
according TAF/TAP TSI Common Schema to partner using the Common Interface (CI).For more detailed Information
please refer to the specification document
</wsdl:documentation>
<wsdl:types>
<xs:schema xmlns:tns="http://uic.cc.org/UICMessage" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified" targetNamespace="http://uic.cc.org/UICMessage" version="1.0">
<xs:element name="UICMessage" type="tns:UICMessage"/>
<xs:element name="UICMessageResponse" type="tns:UICMessageResponse"/>
<xs:complexType name="UICMessage">
<xs:sequence>
<xs:element minOccurs="0" name="message" type="xs:anyType"/>
<xs:element minOccurs="0" name="signature" type="xs:anyType"/>
<xs:element minOccurs="0" name="senderAlias" type="xs:anyType"/>
<xs:element minOccurs="0" name="encoding" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="UICMessageResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xsd:schema xmlns="http://uic.cc.org/UICMessage/Header" xmlns:tns="http://uic.cc.org/UICMessage"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
elementFormDefault="unqualified" targetNamespace="http://uic.cc.org/UICMessage/Header">
<xsd:element name="messageIdentifier" nillable="true" type="xsd:string"/>
<xsd:element name="messageLiHost" nillable="true" type="xsd:string"/>
<xsd:element name="compressed" nillable="true" type="xsd:boolean"/>
<xsd:element name="encrypted" nillable="true" type="xsd:boolean"/>
<xsd:element name="signed" nillable="true" type="xsd:boolean"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="UICMessage">
<wsdl:part element="tns:UICMessage" name="parameters"></wsdl:part>
<wsdl:part element="ns1:messageIdentifier" name="messageIdentifier"></wsdl:part>
<wsdl:part element="ns1:messageLiHost" name="messageLiHost"></wsdl:part>
<wsdl:part element="ns1:compressed" name="compressed"></wsdl:part>
<wsdl:part element="ns1:encrypted" name="encrypted"></wsdl:part>
<wsdl:part element="ns1:signed" name="signed"></wsdl:part>
</wsdl:message>
<wsdl:message name="UICMessageResponse">
<wsdl:part element="tns:UICMessageResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="UICReceiveMessage">
<wsdl:operation name="UICMessage">
<wsdl:documentation>
This operation is used to send the message to the Remote CI.
</wsdl:documentation>
<wsdl:input message="tns:UICMessage" name="UICMessage"></wsdl:input>
<wsdl:output message="tns:UICMessageResponse" name="UICMessageResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="LIReceiveMessageServiceSoapBinding" type="tns:UICReceiveMessage">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="UICMessage">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="UICMessage">
<soap:header message="tns:UICMessage" part="messageIdentifier" use="literal"></soap:header>
<soap:header message="tns:UICMessage" part="messageLiHost" use="literal"></soap:header>
<soap:header message="tns:UICMessage" part="compressed" use="literal"></soap:header>
<soap:header message="tns:UICMessage" part="encrypted" use="literal"></soap:header>
<soap:header message="tns:UICMessage" part="signed" use="literal"></soap:header>
<soap:body parts="parameters" use="literal"/>
</wsdl:input>
<wsdl:output name="UICMessageResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="LIReceiveMessageService">
<wsdl:port binding="tns:LIReceiveMessageServiceSoapBinding" name="UICReceiveMessagePort">
<soap:address
location="http://EXTERNALLOCATION"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
有人可以帮我解决这个问题吗?我觉得这真的很奇怪。
最佳答案
目前我们以一种非常肮脏的方式解决了这个问题。我们首先将消息转换为 XML,然后使用子字符串获取正确的部分。接下来我们用 jaxb 将我们需要的部分转换回对象。如果有人知道一个干净的方法来做到这一点,请告诉我。
jaxbContext = JAXBContext.newInstance(UICMessage.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.setProperty("com.sun.xml.bind.characterEscapeHandler", (CharacterEscapeHandler) (ch, start, length, isAttVal, out) -> out.write(ch, start, length));
StringWriter sw = new StringWriter();
jaxbMarshaller.marshal(request, sw);
String xmlString = sw.toString();
String hackedString = xmlString.substring(xmlString.indexOf("<TrainCompositionMessage"), xmlString.indexOf("</message"));
jaxbContext = JAXBContext.newInstance(TrainCompositionMessage.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
TrainCompositionMessage errorMessage = (TrainCompositionMessage) unmarshaller.unmarshal(new StringSource(hackedString));
关于java - Spring ws - 每个属性都返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61636173/
你能比较一下属性吗 我想禁用文本框“txtName”。有两种方式 使用javascript,txtName.disabled = true 使用 ASP.NET, 哪种方法更好,为什么? 最佳答案 我
Count 属性 返回一个集合或 Dictionary 对象包含的项目数。只读。 object.Count object 可以是“应用于”列表中列出的任何集合或对
CompareMode 属性 设置并返回在 Dictionary 对象中比较字符串关键字的比较模式。 object.CompareMode[ = compare] 参数
Column 属性 只读属性,返回 TextStream 文件中当前字符位置的列号。 object.Column object 通常是 TextStream 对象的名称。
AvailableSpace 属性 返回指定的驱动器或网络共享对于用户的可用空间大小。 object.AvailableSpace object 应为 Drive 
Attributes 属性 设置或返回文件或文件夹的属性。可读写或只读(与属性有关)。 object.Attributes [= newattributes] 参数 object
AtEndOfStream 属性 如果文件指针位于 TextStream 文件末,则返回 True;否则如果不为只读则返回 False。 object.A
AtEndOfLine 属性 TextStream 文件中,如果文件指针指向行末标记,就返回 True;否则如果不是只读则返回 False。 object.AtEn
RootFolder 属性 返回一个 Folder 对象,表示指定驱动器的根文件夹。只读。 object.RootFolder object 应为 Dr
Path 属性 返回指定文件、文件夹或驱动器的路径。 object.Path object 应为 File、Folder 或 Drive 对象的名称。 说明 对于驱动器,路径不包含根目录。
ParentFolder 属性 返回指定文件或文件夹的父文件夹。只读。 object.ParentFolder object 应为 File 或 Folder 对象的名称。 说明 以下代码
Name 属性 设置或返回指定的文件或文件夹的名称。可读写。 object.Name [= newname] 参数 object 必选项。应为 File 或&
Line 属性 只读属性,返回 TextStream 文件中的当前行号。 object.Line object 通常是 TextStream 对象的名称。 说明 文件刚
Key 属性 在 Dictionary 对象中设置 key。 object.Key(key) = newkey 参数 object 必选项。通常是 Dictionary 
Item 属性 设置或返回 Dictionary 对象中指定的 key 对应的 item,或返回集合中基于指定的 key 的&
IsRootFolder 属性 如果指定的文件夹是根文件夹,返回 True;否则返回 False。 object.IsRootFolder object 应为&n
IsReady 属性 如果指定的驱动器就绪,返回 True;否则返回 False。 object.IsReady object 应为 Drive&nbs
FreeSpace 属性 返回指定的驱动器或网络共享对于用户的可用空间大小。只读。 object.FreeSpace object 应为 Drive 对象的名称。
FileSystem 属性 返回指定的驱动器使用的文件系统的类型。 object.FileSystem object 应为 Drive 对象的名称。 说明 可
Files 属性 返回由指定文件夹中所有 File 对象(包括隐藏文件和系统文件)组成的 Files 集合。 object.Files object&n
我是一名优秀的程序员,十分优秀!