将可重复的块发送到webservice

时间:2016-03-18 16:21:21

标签: c#

我试图将可重复的块发送到c#中的web服务。假设远程Web服务接受可重复的名称块,例如

<Persons>
<Names>
   <firstname>bob</firstname>
   <lastname>builder</lastname>
</Names>
<Names>
   <firstname>frank</firstname>
   <lastname>guy</lastname>
</Names>
</Persons>

现在我坚持如何在一次通话中发送数据。当我尝试我只能发送最后的名称标签 以下是我发送的方式

[WebMethod(MessageName = "sendNames")]
[SoapHeader("SoapHeader", Direction = SoapHeaderDirection.InOut)]
public string Names(string firstname, string lastname)
{
    DateTime mydate = DateTime.Now;              
    string format = "yyyyMMdd";     
    var stmtProxy = new NamesNotificationServicePortTypeClient("NamesEndpoint");
    var stmDtl = new Names();
    stmDtl.firstname = firstname;      
    stmDtl.lastname = lastname;
    Names[] stmt2;
    stmt2 = new Names[1];
    stmt2[0] = stmDtl;
    var stmtresponse = stmtProxy.Persons(stmt2);
}

0 个答案:

没有答案