当我尝试将XML提交到在服务器上发布的Web服务时,我收到此错误。当我从Visual Studio上的调试模式提交时,它工作正常。我真的很困惑。任何帮助是极大的赞赏。感谢
XML
data %>%
rowwise() %>%
mutate(y = possibly(my_func_vect, otherwise = NA_real_)(x))
#> Source: local data frame [4 x 2]
#> Groups: <by row>
#>
#> # A tibble: 4 x 2
#> x y
#> <dbl> <dbl>
#> 1 1 1
#> 2 -1 NA
#> 3 4 2
#> 4 9 3
这是用于提交XML的C#代码
<?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:Header>
<AuthUser xmlns="http://xxx.bbb.com/">
<ClientID>xxx</ClientID>
<Username>xxx</Username>
<Password>xxx</Password>
</AuthUser>
</soap:Header>
<soap:Body>
<InsertSecure xmlns="http://xxx.bbb.com/">
<orderXml>
<![CDATA[
<Root>
<County>Dorset</County>
</Root>
]]>
</orderXml>
</InsertSecure>
</soap:Body>
</soap:Envelope>
创建XML方法
[WebMethod(Description = "Use this web service to submit new work orders. This needs authentication")]
[SoapHeader("User", Required = true)]
public XmlDocument InsertSecure(string orderXml)
{
if (User != null) //check whether the credentials are present
{
if (User.IsValid()) // check if the user is valid
{
try
{
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(orderXml);
return createXML(xdoc);
}
catch (Exception ex)
{
}
}
else
{
XmlDocument xAuthDeniedDoc = new XmlDocument();
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version='1.0' encoding='utf-8' ?>");
sb.Append("<DocumentElement>");
sb.Append("<Response>Unauthorized Access");
sb.Append("</Response>");
sb.Append("</DocumentElement>");
xAuthDeniedDoc.LoadXml(sb.ToString());
return xAuthDeniedDoc;
}
}
}
private XmlDocument createXML(XmlDocument xdoc)
{
try
{
string directory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
string filePath = directory + "WebServiceXML\\";
string dateStimeStamp = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
string fileName = "WorksOrderXML-" + dateStimeStamp + ".xml";
xdoc.Save(filePath + fileName);
XmlDocument xSucessDoc = new XmlDocument();
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version='1.0' encoding='utf-8' ?>");
sb.Append("<DocumentElement>");
sb.Append("<SuccessResponse>Order Received Successfully");
sb.Append("</SuccessResponse>");
sb.Append("</DocumentElement>");
xSucessDoc.LoadXml(sb.ToString());
return xSucessDoc;
}
catch(Exception ex)
{
}
}
答案 0 :(得分:0)
实际错误是文件位置,而不是以下内容,
string directory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
string filePath = directory + "WebServiceXML\\";
我用过,
string filePath = @"C:\WebServiceXML\";
谢谢大家。您的意见得到了高度赞赏