gpt4 book ai didi

android - Retrofit Soap 响应 simpleframework 元素 'Body' 没有

转载 作者:搜寻专家 更新时间:2023-11-01 09:31:11 27 4
gpt4 key购买 nike

我正在对 soap 服务使用改造,但出现元素“主体”没有 .. 错误。我不擅长用 SOAP :)这是我的回应和我的对象

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<EncryptResponse xmlns="http://tempuri.org/">
<EncryptResult>%%UmVxdWVzdElzVmFsaWQyOTowMToyMDE1IDE2OjMx%%</EncryptResult>
</EncryptResponse>
</soap:Body>
</soap:Envelope>

加密响应信封

@Root(name = "soap:Envelope")
@NamespaceList({
@Namespace( prefix = "xsi", reference = "http://www.w3.org/2001/XMLSchema-instance"),
@Namespace( prefix = "xsd", reference = "http://www.w3.org/2001/XMLSchema"),
@Namespace( prefix = "soap", reference = "http://schemas.xmlsoap.org/soap/envelope/")
})
public class EncryptResponseEnvelope {

@Element(name = "soap:Body", required = false)
private EncryptResponseBody body;

public EncryptResponseBody getBody() {
return body;
}

public void setBody(EncryptResponseBody body) {
this.body = body;
}
}

加密响应体

@Root(name = "soap:Body", strict = false)
public class EncryptResponseBody {

@Element(name = "EncryptResponse", required = false)
private EncryptResponseData encryptResponseData;


public EncryptResponseData getEncryptResponseData() {
return encryptResponseData;
}

public void setEncryptResponseData(EncryptResponseData encryptResponseData) {
this.encryptResponseData = encryptResponseData;
}
}

加密响应数据

@Root(name = "EncryptResponse", strict = false)
@Namespace(reference = "http://tempuri.org/")
public class EncryptResponseData {

@Element(name = "EncryptResult", required = false)
private String encryptResult;

public String getEncryptResult() {
return encryptResult;
}

public void setEncryptResult(String encryptResult) {
this.encryptResult = encryptResult;
}
}

这是我的错误:

org.simpleframework.xml.core.ElementException: Element 'Body' does not have a match in class com.package.chal.data.response.encrypt_response.EncryptResponseEnvelope at line 1

我哪里出错了?

最佳答案

SOAP 信封:

import org.simpleframework.xml.Element;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.NamespaceList;
import org.simpleframework.xml.Root;

@Root(name="soap:Envelope", strict=false)
@NamespaceList({
@Namespace(reference="http://schemas.xmlsoap.org/soap/envelope/", prefix="soap"),
@Namespace(reference="http://www.w3.org/2001/XMLSchema", prefix="xsd"),
@Namespace(reference="http://www.w3.org/2001/XMLSchema-instance", prefix="xsi")
})
public class Envelope {

@Element(name="Body")
private Body body;

public Body getBody() {
return body;
}

public void setBody(Body body) {
this.body = body;
}
}

SOAP 主体:

import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementUnion;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.Path;
import org.simpleframework.xml.Root;

@Root(strict = false)
@Namespace(reference = "http://schemas.xmlsoap.org/soap/envelope/", prefix = "soap")
public class Body {
// By using ElementUnion, you can re-use the Envelope/Body classes for
// a variety of messages...
@ElementUnion({
// @Element(name="login", type=Login.class),
@Element(name = "EncryptResponse", type = EncryptResponse.class) })
public Object payload;
}

SOAP 负载:

import org.simpleframework.xml.Element;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.Root;

@Root
@Namespace(reference="http://tempuri.org/")
public class EncryptResponse {
@Element
public String EncryptResult;
}

我测试了这个解决方案,它适用于序列化/反序列化。

关于android - Retrofit Soap 响应 simpleframework 元素 'Body' 没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47191071/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com