2017-08-27 66 views
0

我对此很陌生,在创建调用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=\&quot;Web\&quot; /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后:郎消失的错误,但给我留下了这一点:

<SOAP-ENV:Fault> 
<faultcode xmlns="">SOAP-ENV:Server</faultcode> 
<faultstring xmlns="">Call to undefined method X::ActivityId()</faultstring> 
</SOAP-ENV:Fault> 

任何想法?

谢谢。

回答

0

仍然不知道是什么导致了这个错误,但Web服务工作正常。我通过在VS中开始一个新项目来解决它。相同的代码,相同的文件但错误没有出现,并且应用运行良好。