【发布时间】:2018-02-04 20:39:42
【问题描述】:
我是新手,在创建调用 Web 服务的应用程序时偶然发现了一堵墙。我已将 wsdl 添加为服务参考,没有任何问题。我试图调用的方法需要通过用户密钥和登录进行身份验证,但我唯一需要在表单中传递的是登录(没有身份验证它会给我登录失败错误)。我使用 ClientCredentials 传递用户名,但后来我收到了这个:
[CommunicationException: Server returned an invalid SOAP Fault. Please see InnerException for more details.]
还有内部异常:
[XmlException: Required xml:lang attribute value is missing.]
我检查了日志,响应给了我一条奇怪的消息(大部分代码是由文档中的示例提供的):
Call to undefined method X::Action()
老实说,我不知道如何处理这个问题。令人怀疑的是文档是错误的,所以它应该在我这边,但不知道在哪里。另外,这个应用程序应该是一个可以部署在每个站点上的小部件,所以它应该尽可能简单。 你能指出我如何处理这个错误的正确方向吗? 我的 web.config 文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<wsHttpBinding>
<binding name="ApiClientsBinding">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://X/edi/api-clients.php"
binding="wsHttpBinding" bindingConfiguration="ApiClientsBinding"
contract="ServiceClient.ApiClientsPortType" name="ApiClientsPort" />
</client>
</system.serviceModel>
</configuration>
更新: 我一时兴起检查了一些东西,这似乎是一个 SOAP 版本问题。将 wsHttpBinding 更改为 basicBinding 后,xml:lang 错误消失了,但给我留下了这个:
<SOAP-ENV:Fault>
<faultcode xmlns="">SOAP-ENV:Server</faultcode>
<faultstring xmlns="">Call to undefined method X::ActivityId()</faultstring>
</SOAP-ENV:Fault>
有什么想法吗?
谢谢。
【问题讨论】:
标签: c# web-services web soap