我有以下代码示例:
PlentySoapRequest_GetAuthentificationToken username = new PlentySoapRequest_GetAuthentificationToken();
username.Username = user_textbox.ToString();
username.Userpass = password_textbox.ToString();
Uri uri = new Uri("http://www.****.de/plenty/api/soap/version105/");
XNamespace soapenv = @"http://schemas.xmlsoap.org/soap/envelope/";
XNamespace xsi = @"http://www.w3.org/2001/XMLSchema-instance";
XNamespace xsd = @"http://www.w3.org/2001/XMLSchema";
XNamespace ver = @"http://www.****.de/plenty/api/soap/version105/";
var document = new XDocument(
new XDeclaration("1.0", "utf-8", String.Empty),
new XElement(soapenv + "Envelope",
new XAttribute(XNamespace.Xmlns + "xsi", xsi),
new XAttribute(XNamespace.Xmlns + "xsd" , xsd),
new XAttribute(XNamespace.Xmlns + "soapenv" , soapenv),
new XAttribute(XNamespace.Xmlns + "ver" , ver),
new XElement(soapenv + "Header"),
new XElement(soapenv + "Body",
new XElement(ver + "GetAuthentificationToken",
new XElement("oLogin" + xsi + "type" + ver + "PlentySoapRequest_GetAuthentificationToken",
new XAttribute("Username" + xsi + "type" + xsd + "string", username.Username),
new XAttribute("Userpass" + xsi + "type" + xsd + "string", username.Userpass)
)
)
)
)
);
我一直在第一行收到错误消息。“大量的请求……”
The ':' character, hexadecimal value 0x3A, cannot be included in a name.
如果我注释掉这些行,它会一直说它在代码的第一行。
编辑: xml 应该如下所示:
<soapenv:Body>
<ver:GetAuthentificationToken>
<oLogin xsi:type="ver:PlentySoapRequest_GetAuthentificationToken">
<!--You may enter the following 2 items in any order-->
<Username xsi:type="xsd:string">apitest</Username>
<Userpass xsi:type="xsd:string">apitest</Userpass>
</oLogin>
</ver:GetAuthentificationToken>
所以xml-sysntax似乎有问题。我不知道如何设置xsi:type或xsi:type