<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<ActivityId CorrelationId="e5bbf878-4503-4010-aab5-b81d422b66ba" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">f905b59e-f833-44cb-9760-3c6619dc8c6c</ActivityId>
</s:Header>
<s:Body>
<QueryMessage xmlns="http://tempuri.org/">
<messageSet xmlns:a="http://schemas.datacontract.org/2004/07/Sanay.Suip.Library" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:ActionId i:nil="true">?</a:ActionId>
<a:Ip>::1</a:Ip>
<a:Parameters>
<a:Parameter>
<a:Name>Username</a:Name>
<a:Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">tipex</a:Value>
</a:Parameter>
<a:Parameter>
<a:Name>Password</a:Name>
<a:Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">123456</a:Value>
</a:Parameter>
</a:Parameters>
<a:Title>Authenticate</a:Title>
<a:Token>?</a:Token>
<a:Username>tipex</a:Username>
</messageSet>
</QueryMessage>
</s:Body>
这是我的模型课
@root(name=“s:envelope”)@namespace(前缀=“s”,reference=“http://schemas.xmlsoap.org/soap/envelope/”)
公共类信封{
@Element(name = "s:Body")
private Body body;
public Body getBody() {
return body;
}
public void setBody(Body body) {
this.body = body;
}
@Root(name = "x:Body")
@Element(name = "QueryMessage")
private QueryMessage queryMessage;
public QueryMessage getQueryMessage() {
return queryMessage;
}
public void setQueryMessage(QueryMessage queryMessage) {
this.queryMessage = queryMessage;
}
@Root(name = "QueryMessage")
公共类查询消息{
@Element(name = "messageSet")
private MessageSet messageSet;
public MessageSet getMessageSet() {
return messageSet;
}
public void setMessageSet(MessageSet messageSet) {
this.messageSet = messageSet;
}
}
@Root (name = "messageSet")
@namespaceList({@namespace(prefix=“a”,reference=“http://schemas.datacontract.org/2004/07/sanay.suip.library”),@namespace(prefix=“i”,reference=“http://www.w3.org/2001/xmlschema-instance”)})
@Element(name = "ActionId",required = false)
private String actionId;
@Element(name = "Ip")
private String ip;
@ElementList (name = "Parameters")
private List<ModelParameter> modelParameterList;
@Element(name = "Title")
private String title;
@Element(name = "Token",required = false)
private String token;
@Element(name = "Username")
private String username;
public String getActionId() {
return actionId;
}
public void setActionId(String actionId) {
this.actionId = actionId;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public List<ModelParameter> getModelParameterList() {
return modelParameterList;
}
public void setModelParameterList(List<ModelParameter> modelParameterList) {
this.modelParameterList = modelParameterList;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Root(name = "Parameter")
@Element(name = "Name")
private String name;
@Element(name = "Value")
private String value;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
这是我的web服务类
你的课有很多问题。我已经修改和测试过了。我能够将xml转换为对象。
信封类。
/**
* Created by kbiradar on 7/26/2018.
*/
@Root(name = "Envelope")
@Order(elements = {"Header", "Body"})
@Namespace(prefix = "s", reference = "http://schemas.xmlsoap.org/soap/envelope/")
public class Envelope {
@Element(name = "Header")
@Namespace(prefix = "s", reference = "http://schemas.xmlsoap.org/soap/envelope/")
private Header header;
@Element(name = "Body")
@Namespace(prefix = "s", reference = "http://schemas.xmlsoap.org/soap/envelope/")
private Body body;
public Body getBody() {
return body;
}
public void setBody(Body body) {
this.body = body;
}
public Header getHeader() {
return header;
}
public void setHeader(Header body) {
this.header = body;
}
}
头类。
/**
* Created by kbiradar on 7/26/2018.
*/
@Root(name = "Header", strict = false)
public class Header {
static class ActivityId
{
@Attribute
String CorrelationId;
@Text
private String ActivityId;
}
@Element(name = "ActivityId")
ActivityId ActivityId;
}
/**
* Created by kbiradar on 7/26/2018.
*/
@Root(name = "Body", strict = false)
public class Body {
@Element(name = "QueryMessage")
//@Namespace(prefix = "s", reference = "http://schemas.xmlsoap.org/soap/envelope/")
@Namespace(reference = "http://tempuri.org/")
private QueryMessage queryMessage;
public QueryMessage getQueryMessage() {
return queryMessage;
}
public void setQueryMessage(QueryMessage queryMessage) {
this.queryMessage = queryMessage;
}
}
/**
* Created by kbiradar on 7/26/2018.
*/
@Root(name = "QueryMessage")
public class QueryMessage {
@Element(name = "messageSet")
@NamespaceList({ @Namespace( prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library"),
@Namespace( prefix = "i", reference = "http://www.w3.org/2001/XMLSchema-instance") })
private MessageSet messageSet;
public MessageSet getMessageSet() {
return messageSet;
}
public void setMessageSet(MessageSet messageSet) {
this.messageSet = messageSet;
}
}
/**
* Created by kbiradar on 7/26/2018.
*/
@Root(name = "messageSet")
public class MessageSet {
static class ActionId
{
@Attribute
@Namespace(prefix = "i", reference = "http://www.w3.org/2001/XMLSchema-instance")
String nil;
@Text
private String actionId;
}
@Element(name = "ActionId")
@Namespace(prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library")
ActionId actionId;
@Element(name = "Ip")
@Namespace(prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library")
private String ip;
@ElementList(name = "Parameters")
@Namespace(prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library")
private List<ModelParameter> modelParameterList;
@Element(name = "Title")
@Namespace(prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library")
private String title;
@Element(name = "Token",required = false)
@Namespace(prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library")
private String token;
@Element(name = "Username")
@Namespace(prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library")
private String username;
public String getActionId() {
return actionId.actionId;
}
public void setActionId(String actionId) {
this.actionId.actionId = actionId;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public List<ModelParameter> getModelParameterList() {
return modelParameterList;
}
public void setModelParameterList(List<ModelParameter> modelParameterList) {
this.modelParameterList = modelParameterList;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
/**
* Created by kbiradar on 7/26/2018.
*/
@Root(name = "Parameter")
@Namespace(prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library")
public class ModelParameter {
static class value
{
@Attribute
@Namespace(prefix = "i", reference = "http://www.w3.org/2001/XMLSchema-instance")
String type;
@Text
private String value;
}
@Element(name = "Name")
@Namespace(prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library")
private String name;
@Element(name = "Value")
@Namespace(prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library")
@NamespaceList({@Namespace(prefix = "a", reference = "http://schemas.datacontract.org/2004/07/Sanay.Suip.Library"),
@Namespace(prefix = "b", reference = "http://www.w3.org/2001/XMLSchema")})
private value value;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value.value;
}
public void setValue(String value) {
this.value.value = value;
}
}
这是POST请求的实际图像[使用Android改造上传图像,如何使用改造进行多部分请求][2] 我使用翻新发送了多个图像文件和字符串数据,但在服务器端缺少字符串数据 我的保存注册 API
我需要执行修改后的请求,但我有一个问题,我不能很好地理解。在尝试使用代码之前,我用Postman和request测试了api调用,如下所示: 下面是我的android代码: 编辑请求: null
下面是生成授权字符串的函数: 内容类型为“application/x-www-form-urlencoded”,并生成x-Amz-Date,例如:“201805138T120046Z” 然后通过改装方法将其传递: 结果返回null,我确信这个问题与授权有关,因为它以前工作得很好。 谢谢你的帮助:)
我有像4天,试图提出一个多部分的请求使用改型1.8.0在android与任何成功。我的界面如下所示 最后,我决定这样做,其实我的答案很接近@lazypig,这是一个很好的指导方针 我唯一改变的是他的类“ByteArrayTypedOutput” 我创建了一个名为“MultipartTypedOutputCustom”的类http://pastie.org/10549360
我试图使用HttpURLConnection执行post请求,但不知道如何正确执行。 我可以使用以下代码成功地使用Android AsyncHttp客户端执行请求: 可以在台式机上使用curl执行相同的请求: 这两种方法都给了我来自服务器的预期响应。 现在我想使用HttpURLConntions执行相同的请求。问题是我不知道如何正确地执行它。我尝试过这样的事情: 如何正确地将与使用AsyncHtt