用c#

时间:2015-07-05 13:38:53

标签: c# xml web-services soap xsd

我已经构建了一个.net C#webservice。 我的一个方法应该返回一个带有搜索恢复的XML。

当我的方法返回XMLDocument类型时,

我现在的肥皂说明是:

 SOAP 1.1
 The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

 POST /HARELCYBWS/HARELCYBWS.asmx HTTP/1.1
 Host: safemail-t.harel-ins.co.il
 Content-Type: text/xml; charset=utf-8
 Content-Length: length
 SOAPAction: "http://www.securenet.co.il/GetSafeActivitiesXML"

 <?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>
     <GetSafeActivitiesXML xmlns="http://www.securenet.co.il">
       <safename>string</safename>
       <days>int</days>
       <FileName>string</FileName>
     </GetSafeActivitiesXML>
   </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>
     <GetSafeActivitiesXMLResponse xmlns="http://www.securenet.co.il">
       <GetSafeActivitiesXMLResult>xml</GetSafeActivitiesXMLResult>
     </GetSafeActivitiesXMLResponse>
   </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>
     <GetSafeActivitiesXMLResponse xmlns="http://www.securenet.co.il">
       <GetSafeActivitiesXMLResult>
 <results>
 <result>
       <safename>string</safename>
       <days>int</days>
       <username>string</username>
       <numberID>int</numberID>
       <comment>string</comment>
 </result>
 <result>
       <safename>string</safename>
       <days>int</days>
       <username>string</username>
       <numberID>int</numberID>
       <comment>string</comment>
 </result>
 <result>
       <safename>string</safename>
       <days>int</days>
       <username>string</username>
       <numberID>int</numberID>
       <comment>string</comment>
 </result>
 </results>
 </GetSafeActivitiesXMLResult>
     </GetSafeActivitiesXMLResponse>
   </soap:Body>
 </soap:Envelope>

我试着研究图式,血清和所有其他东西,我真的不知道我在那里做什么。 我是xml的新手,我不知道所有的细节。

我该怎么办?另外,XMLDocument是正确的返回类型吗?

请帮忙,

谢谢。

大卫

1 个答案:

答案 0 :(得分:0)

返回类型是表示单个结果类列表的新类。 为我工作。