我怎么能有没有空值的wsdl?还是没有得到帮助 [英] how I can have wsdl without nulls? still haven't received the help
本文介绍了我怎么能有没有空值的wsdl?还是没有得到帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
在以下WSDL中,如何获得地址字段属性?
Hello,
In the following WSDL how can I have the Address Field Properties?
<Address xsi:nil="true" />
<Address xsi:nil="true" />
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<InsertInfo xmlns="http://tempuri.org/">
<id>string</id>
<Personnels>
<Personnel>
<FirstName>string</FirstName>
<Addesses>
<Address xsi:nil="true" />
<Address xsi:nil="true" />
</Addesses>
<Phones>
<Phone xsi:nil="true" />
<Phone xsi:nil="true" />
</Phones>
</Personnel>
<Personnel>
<FirstName>string</FirstName>
<Addesses>
<Address xsi:nil="true" />
<Address xsi:nil="true" />
</Addesses>
<Phones>
<Phone xsi:nil="true" />
<Phone xsi:nil="true" />
</Phones>
</Personnel>
</Personnels>
</InsertInfo>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<InsertInfoResponse xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
以下是我的班级结构...
Below is my class structure...
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Xml.Serialization;
namespace SampleWebService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public void InsertInfo(string id, List<Personnel> Personnels)
{
}
}
}
namespace SampleWebService
{
[XmlRoot("Personnel")]
public class Personnel
{
public string FirstName { get; set; }
[XmlArray("Addesses")]
public List<Address> AddressList { get; set; }
[XmlArray("Phones")]
public List<Phone> PhoneList { get; set; }
}
}
namespace SampleWebService
{
[XmlType]
public class Address
{
[XmlElement]
public string MailingAddress1 { get; set; }
}
}
namespace SampleWebService
{
[XmlType]
public class Phone
{
[XmlElement]
public string PhoneType { get; set; }
[XmlElement]
public int PhoneNumber { get; set; }
}
}
推荐答案
尝试[System.Xml.Serialization.XmlElementAttribute (IsNullable = false)]
描述这里 [ ^ ]。
这篇关于我怎么能有没有空值的wsdl?还是没有得到帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文