WebService XML SoapFormatter
管理 NuGet 程式包
SoapFormatter
使用 FileStream 建立檔案【SoapSerialize.xml】
[HttpGet()]
public IEnumerable<WeatherForecast> Get()
{
#region SoapFormatter Serialize
Company companySerialize = new Company { name = "1234", code = 1 };
SoapFormatter soapCreate = new SoapFormatter();
using (FileStream streamCreate = new FileStream(@"D:\SoapSerialize.xml", FileMode.Create))
{
soapCreate.Serialize(streamCreate, companySerialize);
}
#endregion
}
使用 FileStream 讀取檔案【SoapSerialize.xml】
[HttpGet()]
public IEnumerable<WeatherForecast> Get()
{
#region SoapFormatter Deserialize
Company companyDeserialize = null;
SoapFormatter soapOpen = new SoapFormatter();
using (FileStream streamOpen = new FileStream(@"D:\SoapSerialize.xml", FileMode.Open))
{
companyDeserialize = (Company)soapOpen.Deserialize(streamOpen);
}
var name = companyDeserialize.name;
#endregion
}
Company
[Serializable]
public class Company
{
public int code { get; set; }
public string name { get; set; }
}
SoapSerialize.xml 檔案
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/clr/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<a1:Company id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/nsassem/NewCapital.WebAPI.Controllers/NewCapital.WebAPI%2C%20Version%3D1.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">
<_x003C_code_x003E_k__BackingField>1</_x003C_code_x003E_k__BackingField>
<_x003C_name_x003E_k__BackingField id="ref-2">1234</_x003C_name_x003E_k__BackingField>
</a1:Company>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
*
*
*
相關文章
- 使用services.xml檔案釋出WebServiceXMLWeb
- 【原創】WebService大講堂之Axis2(3):使用services.xml檔案釋出WebServiceWebXML
- 關於iOS-WebService SOAP AFNetworking~> 2.6.3 XML傳參呼叫方法iOSWebXML
- C# WebService返回引數為DataTable報錯“XML文件有錯誤”C#WebXML
- webservice介面Web
- WebService基本Web
- soa == webServiceWeb
- 求助webserviceWeb
- WebService求助Web
- webservice testWeb
- Restful是什麼,SOAP Webservice和RESTful WebserviceRESTWeb
- webservice介面呼叫Web
- WebService程式碼Web
- Webservice On NettyWebNetty
- WebService實戰Web
- 除錯WebService除錯Web
- webservice簡介Web
- 細說WebServiceWeb
- 什麼是webserviceWeb
- Ajax呼叫WebService(一)Web
- C#呼叫webserviceC#Web
- webservice中呼叫structWebStruct
- webservice得到自身IPWeb
- WebService效能問題Web
- WebService 之 Restful ToolWebREST
- js 呼叫 WebService 方法JSWeb
- SpringBoot+webserviceSpring BootWeb
- C#釋出WebServiceC#Web
- java動態呼叫webserviceJavaWeb
- 新增webservice呼叫日誌Web
- Axis2呼叫WebServiceWeb
- WebService學習筆記Web筆記
- webservice傳輸檔案Web
- PHP呼叫Webservice例項PHPWeb
- OFBIZ webservice簡介Web
- 常用WebService一覽表Web
- android處理webserviceAndroidWeb
- SOAP和WebService真是垃圾。Web