【问题标题】:How to convert ASMX Web reference method HttpWebRequest如何转换 ASMX Web 参考方法 HttpWebRequest
【发布时间】:2015-09-19 08:12:13
【问题描述】:

最近我开始创建一个 Xamarin-iOS 应用程序,它使用 ProjectServer PSI WebService。当我将 PSI 添加为 WebReference 并尝试访问 PSI 方法时,我收到 401 未经授权的错误。有趣的是,它在本地网络中运行良好,但在企业网络中出现错误。所以我打算把 WebReference 改成 SOAP - HttpwebRequest 方法。

这是我尝试过的

我正在尝试使用此 url BaseAddress + pwa/_vti_bin/PSI/Resource.asmx?op=GetCurrentUserUid

获取资源 ID
<?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:Body>  
<GetCurrentUserUid xmlns="http://schemas.microsoft.com/office/project/server/webservices/Resource/" />
</soap:Body> 

我将上面的代码作为正文传递。

但是当我使用 HttpWebRequest 执行此操作时,我收到错误 HttpStatusCode InternalServerError System.Net.HttpStatusCode

在响应中我还发现了以下 xml 响应。

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>  
<s:Fault>

xmlns:a="http://Microsoft.Office.Project.Server">a:ProjectServerFaultCode
</faultcode>
<faultstring>
Unhandled Communication Fault occurred
</faultstring>
<detail>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
Object reference not set to an instance of an object.</string></detail>   
</s:Fault>
</s:Body>
</s:Envelope>

我不知道怎么了。所以我的问题是,

是否可以使用 HttpWebRequest 调用 PSI 方法 如果不是,还有什么办法。

请帮忙。提前致谢。

【问题讨论】:

    标签: c# .net xamarin psi


    【解决方案1】:

    这里有一些项目:

    • URL 应该是:BaseAddress + pwa/_vti_bin/PSI/Resource.asmx
    • SOAP 操作标头:ReadResource
    • 在您的示例中,soap:body 应该是...

      <SOAP:BODY>
      <ReadResource>
      <resourceUid>value</resourceUid>
      </ReadResource>
      </SOAP:BODY>
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多