我需要从Java调用用.NET编写的Web服务.Web服务实现了WS-Security堆栈(WSE 2或WSE 3,从我的信息中不清楚).
我从服务提供商处收到的信息包括WSDL,policyCache.config文件,一些示例C#代码以及可以成功调用服务的示例应用程序.
这听起来没那么有用,因为我不清楚我应该如何使用这些信息来编写Java客户端.如果Web服务请求未根据策略签名,则服务将拒绝该服务请求.我正在尝试使用Apache Axis2,我找不到任何有关如何使用policyCahce.config文件和WSDL来生成客户端的说明.
我在网上找到了几个例子,但在所有情况下,示例的作者都控制了服务和客户端,因此能够对双方进行调整以使其工作.我不在那个位置.
有人做过这个吗?
这是我的问题.我正在访问一个Web服务(托管在基于Java的服务器上),它只接受文本编码的请求,但它返回MTOM响应.我发现如果我将Web服务设置为RequireMtom,它会发送一个Mtom请求!不幸的是,服务器在Mtom请求上窒息并返回500错误.但是,如果我将其设置为文本消息编码,则响应会使用多部分MIME(MTOM)响应正确返回,该响应会使Microsoft Web服务API出错(下面的示例错误).它期望文本编码响应,因为请求是文本编码的.我想仅在响应中使用RequireMtom.有人能帮我一下吗?
正如您在下面的错误中看到的那样(使用标准Web服务API,WCF或WSE3),当我使用文本编码发送请求时,响应会正确返回多部分/相关响应中的所有数据,但是.net框架扼流圈!
WSE的错误消息:
Client found response content type of 'multipart/related; type="text/xml"; start="<1AE0B46A85B0186B5D136D12E1EE286E>"; boundary="----=_Part_209564_1891070135.1226526701833"', but expected 'text/xml'.
The request failed with the error message:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at TestWseService.AdesaJasperWse.ManagementServiceService.runReport(String requestXmlString) in C:\Documents and Settings\xxx\My Documents\Visual Studio 2005\Projects\TestWseService\Web References\AdesaJasperWse\Reference.cs:line 229
at TestWseService.Form1.buttonRunService_Click(Object sender, EventArgs e) in C:\Documents and Settings\xxx\My Documents\Visual Studio 2005\Projects\TestWseService\Form1.cs:line 42
Run Code Online (Sandbox Code Playgroud)
WCF的错误消息
The content type multipart/related; type="text/xml"; start="<30ED8FE3004CDA67723CC7164A6CFEEC>"; boundary="----=_Part_209545_389093169.1226526546805" of the response message does not match the content …
Run Code Online (Sandbox Code Playgroud) 我目前正在研究通过WSE 3.0或WCF加密和签名SOAP消息的主题.由于我没有参与涉及公共Internet的分布式应用程序开发,因此我发现我对X.509证书缺乏知识以及它在Windows证书存储机制中的工作原理.它不是关于非对称密码学; 它是关于PKI生态系统的.
因此,我想收集一些文章或书籍,这些文章或书籍对Windows的安全机制,如何正确使用和管理证书存储,CA信任链以及WSE或WCF等API如何交互并使用证书进行全面解释.建议?
为此,我一直都在网上.我刚刚做了一段时间的恶魔,我试图消费的网络服务供应商拒绝正式支持WCF作为一种消费方法.
我不是网络服务专家,所以我会尽力记录和解释这篇文章,但无论如何,如果你需要的话,请求更多的信息,希望我能够提供任何必要的东西.
服务
在我的公司,我们使用公开服务的供应商应用程序.该应用程序是用java编写的,看起来wsdl是用Apache Axis 1.2创建的.
代码
我的遗留代码使用WSE 3.0.特别是,它使用最后自动添加"WSE"的代理类.这允许我使用更简单的身份验证方案(我可以让它工作的唯一方法).我不需要使用证书.我使用的衍生物SecurityPolicyAssertion
,并将其包装在一个Policy
传递给SetPolicy
客户端类的方法的对象中.以下是创建客户端工作实例所需的全部内容:
MyWebServiceWse api = new MyWebServiceWse();
api.Url = myUrl;
api.SetPolicy(new Policy(new MyDerivedSecurityAssertion(user, pass)));
Run Code Online (Sandbox Code Playgroud)
我的默认,开箱即用的WCF代码(使用服务引用生成)不接受凭据,所以我知道这是一个问题.我已经在网上阅读了关于security
在我的网站中使用不同或绑定设置的各种内容app.config
,但没有任何内容完全奏效.经过大量修补后,我最常见的错误是WSDoAllReceiver: Request does not contain required Security header
.
这是app.config.也许我们可以先告诉我这里应该改变什么来促进传递证书 - 再次,我在网上看到了不同的意见.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MySoapBinding" 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">
<transport clientCredentialType="None" proxyCredentialType="None" …
Run Code Online (Sandbox Code Playgroud) 我们有一个Web服务,包含WSE 3.0端点和.NET Framework 4.5上的新WCF端点.
WCF正在使用basicHttpBinding
.
问题是新的WCF绑定似乎明显更慢(~3x).引擎盖下是否使用相同的机制?
我已经阅读了很多关于启用WCF跟踪的内容.但是当我在生产中启用它时,我得到了很多信息并且不知道如何阅读,例如Microsoft Trace Viewer中的时间线.
我将不胜感激任何帮助
笔记:
生产中存在问题; 在测试服务器上一切都很顺利.起初我们怀疑负载均衡器可能是一个因素,但是禁用负载均衡器根本不会改变性能
缓慢可能是由于我们的应用程序/域层.也许某些线程/连接池正在阻塞,并且消息因此而排队.
在这种情况下,是否有人知道为什么行为与WSE(在同一个应用程序池上运行)如此不同?WSE3.0和WCF之间的队列大小/并发处理默认配置是否发生了显着变化?
有没有办法找出这种情况何时发生?比如
perfmon
要看一些柜台?在perfmon
我刚刚迷路可用的性能计数器的巨额之间进行选择
这是我们的服务Web.config的匿名版本:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="microsoft.web.services2" type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration, Microsoft.Web.Services2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<system.web>
<httpRuntime executionTimeout="900" maxRequestLength="10240" />
<webServices>
<!--<wsdlHelpGenerator href="CustomizedWebServicePage.aspx" />-->
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
<soapExtensionTypes>
<add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1" …
Run Code Online (Sandbox Code Playgroud) 在HTTP Connection标头中,我的Web服务客户端包括:
Connection: Keep-Alive
我想禁用它. 在做了一些研究之后,看来这样做的方法是将SoapHttpChannelOptions
类的KeepAlive成员设置为false.但是,我没有看到SoapHttpChannelOptions
使用WSE3.0(Web服务增强)在Visual Studio中为我生成的Web服务客户端类中访问/修改的方法.
在我的例子中,生成的存根类扩展 Microsoft.Web.Services3.WebServicesClientProtocol
我一直无法找到任何搜索谷歌的例子,SoapHttpChannelOptions类的大多数成员都被继承到WebServicesClientProtocol类......
SoapHttpChannelOptions参考
WebServicesClientProtocol Reference
注意:我不是要修改Web服务器.我正在尝试修改Web服务客户端.
我的任务是创建一个将由外部客户端使用的WCF服务.客户端使用WSSE安全性,具体来说,它们通过SOAP头传递用户名令牌.
WCF服务托管在启用了SSL的IIS服务器上.
在这一点上,我有一个半工作原型.我现在要处理的问题是SOAP标头的mustUnderstand属性设置为1,这会导致进程失败.
我想要一些关于如何处理用户名令牌的建议(或者更好的是,代码示例微笑),以便在mustUnderstand属性为true时返回正确的响应.
以下是失败的SOAP请求示例:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>TestUser</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">TestPWD</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">NzU3MjFhN2YtYTlmYS00ZWZjLTkxNjktY2ExZjlkZDEwNzE5</wsse:Nonce>
<wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2011-10-26T03:04:39Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<tem:Getstuff>
<tem:Arg1>Arg1</tem:Arg1>
<tem:Arg2>Arg2</tem:Arg2>
</tem:Getstuff>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
如果soapenv:mustUnderstand ="1"更改为soapenv:mustUnderstand ="0",则该过程有效.
PS:这是客户发送的修订样本请求:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/WService/Getstuff</Action>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="removed" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Username>TestUser</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">TestPass</wsse:Password>
<wsse:Nonce>2Udx78sh2y2xRJYJpZZ9+w==</wsse:Nonce>
<wsu:Created>2011-09-26T19:12:48Z</wsu:Created>
</wsse:UsernameToken>
</Security>
</s:Header>
<s:Body>
<Getstuff xmlns="http://tempuri.org/">
<Arg1>Arg1</Arg1>
<Arg2>Arg2</Arg2>
</Getstuff>
</s:Body>
</s:Envelope>
Run Code Online (Sandbox Code Playgroud)
我收到以下对上述请求的回复:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:MustUnderstand</faultcode>
<faultstring xml:lang="en-US">The header 'Security' from the namespace 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' was not …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用WSE 3.0从MVC3 .NET Web应用程序调用Java Web Service.
但是,Web服务在UsernameToken的Nonce元素上需要"EncodingType"属性.以下是一个示例SOAP信封,可以正常使用此Java Web服务:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:v1="http://schema.mydomain.org/sms/v1_0">
<soap:Header>
<wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>myUsername</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">myPassword</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">XQkp6oYc3DRv41cxkSTW8w==</wsse:Nonce>
<wsu:Created>2011-09-13T20:50:08.355Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<v1:ping/>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
以下是从VS2010生成的代理生成的SOAP信封(在Fiddler中捕获):
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<wsse:Security env:mustUnderstand="true">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-111f922b-72c1-4057-bce4-f6555552ce6a">
<wsse:Username>myUsername</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">myPassword</wsse:Password>
<wsse:Nonce>qYse3Lor9sAJ9pKPefgkKQ==</wsse:Nonce>
<wsu:Created>2011-09-13T20:50:38Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>
<soap:Body>
<v1:ping/>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
如果缺少此属性,则此Web服务将返回"提供了无效的安全令牌(处理用户名令牌时发生错误)"
如何添加EncodingType属性?
我在visual studio 2013中有一个asp.net网站.我添加了一个web服务.我需要将身份验证参数(用户名和密码)作为SOAP标头发送.但它无法找到属性RequestSoapContext.
我添加了使用Microsoft.Web.Services3; 在我的代码中.
CCWS.Service proxy = new CCWS.Service();
UsernameToken userToken = new UsernameToken("", "", PasswordOption.SendPlainText);
proxy.RequestSoapContext.Security.Tokens.Add(token);
Run Code Online (Sandbox Code Playgroud)
一些论坛说要在reference.cs文件中更改引用类型.但我在我的解决方案中找不到任何此类文件.有人可以帮忙吗?
我意识到这个问题涉及旧技术.我正在调用供应商系统,无法更改服务.我们需要调用XML/SOAP WS,然后对请求进行签名.10年前,我会使用像Web Services Enhancements(WSE)3.0这样的东西,然后继续前进.就像今天一样,我仍然坚持在.Net Core(.Net Standard 2.0)应用程序中做什么.
我愿意使用多种解决方案,包括商业解决方案.我看着奇尔卡特,但似乎我们放弃了太多使用它.
然而,他们确实有一个很好的例子.
给出如下请求:
<?xml version="1.0" encoding="UTF8"?>
<SOAP-ENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" SOAP-ENV:mustUnderstand="1">
<wsse:BinarySecurityToken
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509"
wsu:Id="x509cert00">BASE64_CERT</wsse:BinarySecurityToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="TheBody">
<getVersion xmlns="http://msgsec.wssecfvt.ws.ibm.com"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Run Code Online (Sandbox Code Playgroud)
我们希望能够使用证书并签名如下:
<?xml version="1.0" encoding="UTF8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" SOAP-ENV:mustUnderstand="1">
<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://doc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wC7ovecfSqNflT4NMAThSuxpGp8Ugf7a24LXozLzL
bCRvG9sLGyRneZbfU8B43ELRLCkjzWR32N7D2pmKk4CEMiW0ScphU1JEHaimneMa
TFc63hNzKpuj7+BGv4ZuvB1j/Mbmz53PGgFKnGQHPb2TIvMxyB+lML5vE0Bm8YWt
P8DNyx11CCCdBdMWfeta6MjmmqcV5/YEq92c5O2Ql94tWFNLR6wQ</wsse:BinarySecurityToken>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="wsse SOAP-ENV" …
Run Code Online (Sandbox Code Playgroud) wse ×10
wcf ×5
web-services ×5
.net ×4
c# ×4
asp.net ×1
asp.net-core ×1
axis2 ×1
certificate ×1
java ×1
keep-alive ×1
mtom ×1
nonce ×1
performance ×1
pki ×1
security ×1
soap ×1
ws-security ×1
wse3.0 ×1
x509 ×1
xml ×1