使用C#2012和.NET 4.5构建的Web Service Client问题 [英] Issue with Web Service Client built using C# 2012 and .NET 4.5

查看:53
本文介绍了使用C#2012和.NET 4.5构建的Web Service Client问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题让我头疼了好几天了。它是使用C#,.NET 4.5和Visual Studio 2012的Web服务客户端的实现



我可以访问Web服务端点并创建服务参考。但是会生成以下警告:



警告1自定义工具警告:检测到无法访问的策略。 
WSDL中嵌入的WS-Policy元素缺少片段标识符。任何WS-PolicyAttachment机制都不能引用此策略。
XPath:// wsdl:definitions [@ targetNamespace ='http://www.somecompany.com/schema/fulfilment/deployment/edi/inbound/v2/'] / wsdl:definitions [@ name ='EDI10somecompanyService '] C:\ ALPHAHSEDI10 \ somecompanyServiceSend \ somecompanyServiceSend\Service References \EDI10HSS2 \Reference.svcmap

警告2自定义工具警告:未导入以下策略断言:
XPath:// wsdl:definitions [@ targetNamespace ='http://www.somecompany.com/schema/fulfilment/deployment/edi/inbound/v2/'] / wsdl:binding [@ name ='EDI10somecompanyServiceSOAP'] / wsdl:operation [@ name ='UpdateJob'] / wsdl:input
断言:
< sp:SecurityToken xmlns:sp = ' http://schemas.xmlsoap.org/ws/2002/12/secext' > ..< / sp:SecurityToken >
< span class =code-keyword>< sp:SupportingTokens xmlns:sp =' http://docs.oasis-open.org / ws-sx / ws-securitypolicy / 200512' > .. < < span class =code-leadattribute> / sp:SupportingTokens >
C:\ ALPHAHSEDI10 \ somecompanyServiceSend \ somecompanyServiceSend \服务参考\ EDI10HSS2 \Reference.svcmap



我认为*在通过服务引用构建和使用此方法时,无法访问的策略会产生影响。



当实例化一个类实例时:



Somecompany Send.EDI10SC.EDI10ComeCompanyServiceClient edi10sc = new EDI10ComeCompanyServiceClient(configurationname,remoteaddress);



引发以下异常:



在ServiceModel客户端配置部分找不到名为EDI10SomeCompanyService的端点元素和合同EDI10SC.EDI10ComeCompanyService。这可能是因为没有找到您的应用程序的配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。



I我非常确定远程地址和端点值是否正确。我用它们来访问wsdl并构建服务引用。



现在我不知道这两个问题是否相关,我希望有一个Web服务大师在这里可以散发一些光芒。我在Web服务方面的经验不是很好;我过去做过几次服务但从未遇到过这种情况。



我解决这个问题的原因是我想要建立的网络服务是在一个完全不同的公司,我在那里的联系知道的不仅仅是我关于这个东西:-(



任何帮助非常感谢。

解决方案

这已经解决了! />


谈论一个菜鸟错误..我将Classname和Namespace名称设置为相同的东西。这会让Visual Studio陷入困境而不会给你一个警告。

I have an issue which has been causing me a headache for a few days now. It is the implementation of a Web Service Client using C#, .NET 4.5 and Visual Studio 2012

I can access the Web Service Endpoint and create the Service Reference. However the following warnings are generated:

Warning 1   Custom tool warning: Unreachable policy detected.
A WS-Policy element embedded in WSDL is missing a fragment identifier. This policy cannot be referenced by any WS-PolicyAttachment mechanisms.
XPath://wsdl:definitions[@targetNamespace='http://www.somecompany.com/schema/fulfilment/deployment/edi/inbound/v2/']/wsdl:definitions[@name='EDI10somecompanyService']  C:\ALPHAHSEDI10\somecompanyServiceSend\somecompanyServiceSend\Service References\EDI10HSS2\Reference.svcmap 

Warning 2   Custom tool warning: The following Policy Assertions were not Imported:
  XPath://wsdl:definitions[@targetNamespace='http://www.somecompany.com/schema/fulfilment/deployment/edi/inbound/v2/']/wsdl:binding[@name='EDI10somecompanyServiceSOAP']/wsdl:operation[@name='UpdateJob']/wsdl:input
  Assertions:
    <sp:SecurityToken xmlns:sp='http://schemas.xmlsoap.org/ws/2002/12/secext'>..</sp:SecurityToken>
    <sp:SupportingTokens xmlns:sp='http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512'>..</sp:SupportingTokens>
    C:\ALPHAHSEDI10\somecompanyServiceSend\somecompanyServiceSend\Service References\EDI10HSS2\Reference.svcmap


I *think* that the unreachable policy is having a knock on effect when building and using this through the service reference.

When instantiating a class instance thus:

SomecompanySend.EDI10SC.EDI10ComeCompanyServiceClient edi10sc = new EDI10ComeCompanyServiceClient(configurationname, remoteaddress);

the following exception is thrown:

Could not find endpoint element with name 'EDI10SomeCompanyService' and contract 'EDI10SC.EDI10ComeCompanyService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.

I am pretty sure the remote address and endpoint values are correct. I used them to access the wsdl and build the service reference.

Now I don't know if the two issues are related, I am hoping there is a Web Service etc. Guru on here who can shed some light. My experience with Web Services is not great; I have done a couple of services in the past but never encountered this.

The problem I have in resolving this is that the web service I am trying to build for is at a completely different company and my contact there knows not much more than me about this stuff :-(

Any help much appreciated.

解决方案

This is resolved!

Talk about a rookie mistake .. I had the Classname and Namespace name set to be the same thing. This confuses the hell out of Visual Studio without giving you a warning.


这篇关于使用C#2012和.NET 4.5构建的Web Service Client问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆