简体   繁体   English

从.NET代码调用Java Web服务时出错?

[英]Error calling Java web service from .NET code?

I'm getting an error in code that calls a Java web service. 我在调用Java Web服务的代码中遇到错误。 The code works fine on the rest of my team's PCs. 该代码可在我团队的其他PC上正常运行。 I have exactly the same copy of the source code. 我有完全相同的源代码副本。 So I'm guessing it's a configuration issue on my PC buried deep somewhere and has nothing to do with the source code itself? 因此,我猜这是我的PC埋在某个地方的配置问题,与源代码本身无关吗?

The error I get is: 我得到的错误是:

The HTTP request was forbidden with client authentication scheme 'Anonymous' 客户端身份验证方案“匿名”禁止HTTP请求

Here are the 2 configuration sections from the web.config. 这是来自web.config的2个配置部分。

<binding
  name="SEITokenServiceBinding"
  closeTimeout="00:01:00"
  openTimeout="00:01:00"
  receiveTimeout="00:10:00"
  sendTimeout="00:01:00"
  allowCookies="false"
  bypassProxyOnLocal="false"
  hostNameComparisonMode="StrongWildcard"
  maxBufferSize="65536"
  maxBufferPoolSize="524288"
  maxReceivedMessageSize="65536"
  messageEncoding="Text"
  textEncoding="utf-8"
  transferMode="Buffered"
  useDefaultWebProxy="true">
  <readerQuotas
    maxDepth="32"
    maxStringContentLength="8192"
    maxArrayLength="16384"
    maxBytesPerRead="4096"
    maxNameTableCharCount="16384" />
  <security
    mode="None"/>
</binding>
<client>
    <endpoint
      address="http://10.1.1.1:8180/tokenService"
      binding="basicHttpBinding"
      bindingConfiguration="SEITokenServiceBinding"
      contract="TokenService.SEITokenService"
      name="SEITokenServicePort">
      <identity></identity>
    </endpoint>
</client>

I have seen this issue before in my work place. 我以前在工作场所已经看到过这个问题。 It may be totally different for you, but I will share my expereince. 对于您来说可能完全不同,但是我会分享我的经验。

In my scenario, it was to do with a different group policy being applied to one of the development PC's and not to all the other development PC's, which resulting in the current users credentials not being passed to the internal proxy server. 在我的方案中,这与将不同的组策略应用于一个开发PC而不是应用于所有其他开发PC有关,这导致当前用户凭据未传递到内部代理服务器。

I would recommend trying to explicitly set an identity for the service in the web.config (maybe your own userid) and see if that resolves the issue. 我建议尝试在web.config中显式设置服务的标识(也许是您自己的用户ID),看看是否可以解决问题。

That however is only a temporary solution, you need to discover the difference in the group policies and have them amended so that the staging / development systems are all the same. 但是,这只是一个临时解决方案,您需要发现组策略中的差异并进行修改,以使登台/开发系统完全相同。

Don't know the answer, but a good way to debug it would be to run a debugging http proxy like Fiddler on your machine. 不知道答案,但是调试它的一种好方法是在计算机上运行调试的HTTP代理,例如Fiddler Grab the http conversation and diff it with the output from a colleague's machine that does not exhibit the issue. 抓住http对话,并将其与未显示该问题的同事的计算机的输出进行比较。

这是由于Java Web服务服务器上的IP子网限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM