0
SOAP Webservice를 처음 사용합니다. 다음 XML을 달성하는 방법을 제안하십시오.직렬화 중에 C에서 배열 목록 항목에 속성을 부여하는 방법 #
나는 이런 식으로 XML 조각을 만드는 C#을 생성하려고합니다.
<?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>
<querySeatResponse xmlns="xxx">
<querySeatResult>
<querySeat_status code="int" msg="string">
<details>
<detail seat_no="string" available="string" />
<detail seat_no="string" available="string" />
</details>
</querySeat_status>
</querySeatResult>
</querySeatResponse>
</soap:Body>
</soap:Envelope>
하지만 점점 오전 다음 출력 :
<?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>
<querySeatResponse xmlns="xxx">
<querySeatResult>
<querySeat_status code="int" msg="string">
<details>
<detail xsi:nil="true" />
<detail xsi:nil="true" />
</details>
</querySeat_status>
</querySeatResult>
</querySeatResponse>
</soap:Body>
</soap:Envelope>
내 소스 코드를 다음과 같이,
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class abc : System.Web.Services.WebService
{
[WebMethod]
[SoapDocumentMethod("xxx", RequestNamespace = "xxx", ResponseNamespace = "xxx", Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public querySeat_Main querySeat([XmlAttribute] string signature, string operator_code, string route_id, string trip_no, string depart_date, string counter_from, string counter_to, string bus_type)
{
querySeat_Main main = new querySeat_Main();
querySeat_status status = new querySeat_status();
querySeat_status.detail detail = new querySeat_status.detail();
status.code = 0;
status.msg = "success";
main.querySeat_status = status;
return main;
}
}
[Serializable]
[GeneratedCode("System.Xml", "xxxx")]
[XmlType(Namespace = "xxx")]
[DebuggerStepThrough]
[DesignerCategory("code")]
public class querySeat_Main
{
querySeat_status status;
public querySeat_Main()
{
}
public querySeat_status querySeat_status { get { return status; } set { status = value; } }
}
[Serializable]
[GeneratedCode("System.Xml", "xxx")]
[XmlType(Namespace = "xxx")]
[DebuggerStepThrough]
[DesignerCategory("code")]
[XmlRoot("querySeat_status", Namespace = "xxx")]
public class querySeat_status
{
int Code;
string Msg;
public querySeat_status() { }
[XmlAttribute]
public int code { get { return Code; } set { Code = value; } }
[XmlAttribute]
public string msg { get { return Msg; } set { Msg = value; } }
[XmlArray("details")]
[XmlArrayItem("detail")]
public List<detail> details = new List<detail>();
[Serializable]
[GeneratedCode("System.Xml", "xxx")]
[DebuggerStepThrough]
[DesignerCategory("code")]
[XmlRoot("querySeat_status", Namespace = "xxx")]
public class detail
{
string seat;
string avail;
public detail() { }
[XmlAttribute]
public string seat_no { get { return seat; } set { seat = value; } }
[XmlAttribute]
public string available { get { return avail; } set { avail = value; } }
}
}
'status.details.Add (detail)'이 누락 되었습니까? –
어디 제안 할 수 있습니까? – CnuVas
'detail'과'return main'을 만드는 사이의 모든 곳. 일반적으로'detail' 인스턴스를 초기화 한 직후에 완료됩니다. –