我在ksoap2中使用envelope.addMapping函数,我需要让它生成没有i:type属性的项目.
这是我的代码生成的soap请求
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://www.w3.org/2003/05/soap-encoding"
xmlns:v="http://www.w3.org/2003/05/soap-envelope">
<v:Header>
<ApiKey xmlns="urn:example:data">APIKey</ApiKey>
</v:Header>
<v:Body>
<CreateScan xmlns="urn:example:services" id="o0" c:root="1">
<scan i:type="n3:" xmlns:n3="">
<n4:BaseUrl i:type="d:string" xmlns:n5="urn:example:data">http://www.example.com</n5:BaseUrl>
<n5:DisplayName i:type="d:string" xmlns:n7="urn:example:data">Example Scan</n7:DisplayName>
</scan>
</CreateScan>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)
我需要这样<scan i:type="n3:scanItem" xmlns:n3="">生成它 <scan>
这是我的代码
package ksoap2.test;
import java.util.Hashtable;
import java.util.Vector;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.ksoap2.transport.HttpTransportSE;
import org.kxml2.kdom.Element;
import org.kxml2.kdom.Node;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class ksoap2 extends Activity {
/** Called when the activity …Run Code Online (Sandbox Code Playgroud) 我试图让一个非常简单的项目作为地址阅读器.出于某种原因,当我设置从编辑表单获取Post数据响应的方法时,它只有在我设置它以查找单个变量才能正确读取发布数据但是如果我将其设置为接受复杂项目时失败.
这是我的控制器代码:
[HttpGet]
public ActionResult Index()
{
ViewBag.Message = "";
Address address = new Address();
return View(address);
}
[HttpPost]
//public ActionResult Index(String Name, String Street1, String Street2, String City, String State, String Zip)
public ActionResult Index(Address model)
{
Address address = model;
//check ModelState
if (!ModelState.IsValid)
return View(address);
else
{
ViewBag.Message = "Save Success";
address = new Address();
return Redirect("/");
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用注释掉的行,所有这些行都被正确填充,但如果我使用该public ActionResult Index(Address model)行,则模型变量保持为空.
这是我的视图的表单代码:
@using (Html.BeginForm())
{
@Html.ValidationSummary()
<fieldset>
<legend>Your Address</legend>
<p>@Html.LabelFor(model => model.Name) @Html.TextBoxFor(model …Run Code Online (Sandbox Code Playgroud)