我必须为SOAP请求生成如下所示的XML字符串。
<soapenv:Body>
<user:getUserProfile>
<user:getUserProfileInput>
<requestorInfoDVO>
<dvo:ApplicationName>?</dvo:ApplicationName>
<!--Optional:-->
<dvo:HostName>?</dvo:HostName>
<!--Optional:-->
<dvo:CorrelationId>?</dvo:CorrelationId>
</requestorInfoDVO>
<dvo1:getUserProfileInputDVO>
<dvo1:effectiveDate>?</dvo1:effectiveDate>
<dvo1:commissionLevelServiceInputDVO>
<dvo1:UserCode>?</dvo1:UserCode>
<dvo1:stateCode>?</dvo1:stateCode>
<dvo1:marketCode>?</dvo1:marketCode>
<dvo1:program>?</dvo1:program>
<!--Optional:-->
<dvo1:lob>?</dvo1:lob>
<!--Optional:-->
<dvo1:reportingOffice>?</dvo1:reportingOffice>
<!--Optional:-->
<dvo1:userTypeCd>?</dvo1:userTypeCd>
</dvo1:commissionLevelServiceInputDVO>
</dvo1:getUserProfileInputDVO>
</user:getUserProfileInput>
</user:getUserProfile>
</soapenv:Body>
我已使用以下代码请求以字符串格式获取XML格式。
以下是我的C#代码
var request = new getUserProfile
{
getUserProfileInput = new getUserProfileInput
{
getUserProfileInputDVO = new GetUserProfileInputDVO
{
effectiveDate = DateTime.Now,
commissionLevelServiceInputDVO = new CommissionLevelServiceInputDVO
{
marketCode = "test",
program = "QQ",
stateCode = "CT",
UserCode = "A User"
}
},
requestorInfoDVO = new RequestInfoDVO
{
ApplicationName = "TESTAPP",
CorrelationId = Guid.NewGuid().ToString(),
HostName = "LOCALHOST"
}
}
};
XmlSerializer xmlSerializer = new XmlSerializer(request.GetType());
string test = string.Empty;
using (StringWriter textWriter = new StringWriter())
{
xmlSerializer.Serialize(textWriter, request);
test = textWriter.ToString();
}
但我得到了以下结果。
<getUserProfile>
<getUserProfileInput>
<getUserProfileInputDVO>
<effectiveDate>2018-02-15T18:44:31.9012149+05:30</effectiveDate>
<commissionLevelServiceInputDVO>
<marketCode>test</marketCode>
<program>QQ</program>
<stateCode>CT</stateCode>
<UserCode>A User</UserCode>
</commissionLevelServiceInputDVO>
</getUserProfileInputDVO>
<requestorInfoDVO>
<ApplicationName>TESTAPP</ApplicationName>
<CorrelationId>ca003779-3874-4933-8577-c03bc00670c5</CorrelationId>
<HostName>LOCALHOST</HostName>
</requestorInfoDVO>
但是我需要用户的结果:,dvo:,dvo:1动态别名。 那么,我可以做什么来获取上述类型的XML? 那么,有没有办法在XML序列化的请求中获得结果或我可以做的任何更改?