wsimport
을 사용하여 클라이언트 코드를 생성하는 WSDL 사양이 있습니다. (내가 전에 여러 번 해왔 던 것처럼).SOAP, JAXB 정렬 동작
지금 XSD의 유형 중 하나
<xs:complexType name="Credential">
<xs:sequence>
<xs:element minOccurs="0" name="UID" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="UIDBranch" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="PWD" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="Signature" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
그리고 해당 자바 바인딩 :
<ns2:Credentials>
<ns4:string>login</ns4:string>
<ns4:string>password</ns4:string>
<ns4:string>signature</ns4:string>
</ns2:Credentials>
:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Credential", namespace = "http://schemas.datacontract.org/2004/07/...", propOrder = {
"uid",
"uidBranch",
"pwd",
"signature"
})
public class Credential {
@XmlElementRef(name = "UID", namespace = "http://schemas.datacontract.org/2004/07/...", type = JAXBElement.class, required = false)
protected JAXBElement<String> uid;
@XmlElementRef(name = "UIDBranch", namespace = "http://schemas.datacontract.org/2004/07/...", type = JAXBElement.class, required = false)
protected JAXBElement<String> uidBranch;
@XmlElementRef(name = "PWD", namespace = "http://schemas.datacontract.org/2004/07/...", type = JAXBElement.class, required = false)
protected JAXBElement<String> pwd;
@XmlElementRef(name = "Signature", namespace = "http://schemas.datacontract.org/2004/07/...", type = JAXBElement.class, required = false)
protected JAXBElement<String> signature;
... the rest: getters/setters
요청에 이러한 유형의 요소가 같이 일어나는
그러나 형식 안에있는 요소의 이름이 손실되면 위의 조각은 다음과 같아야합니다.
<ns2:Credentials>
<ns4:UID>login</ns4:UID>
<ns4:PWD>password</ns4:PWD>
<ns4:Signature>signature</ns4:Signature>
</ns2:Credentials>
왜 클라이언트가 올바른 방식으로 작동하도록 할 수 있습니까?
업데이트 자격 증명 (of
가 ObjectFactory
이다)이 같은 개체가 만들어집니다 : 당신이 of.createString(login)
을 사용하기 때문에
Credential cr = of.createCredential()
cr.setUID(of.createString(login))
cr.setPWD(of.createString(password))
cr.setSignature(of.createString(sign))
어떻게 'Credentials' 객체를 구성합니까? – lexicore
@lexicore 질문에서 업데이트 됨 – dmitry