2014-09-30 73 views
2

我们目前正在重新开发一个遗留项目,该项目利用Lumesse的SOAP Web服务,通​​过HTTPS调用。Lumesse Web服务和WSSE纯文本安全问题

http://developer.lumesse.com/Getting_Started

这在ASP.NET应用程序被消耗;最初的开发人员(他早已离开)从未利用使用提供的WSDL的优势,宁愿手动构建请求并解析响应。虽然这是非常疯狂的,但这是Lumesse的文档实际上建议从.NET中消费时推荐,因为他们的服务使用过时的WSSE纯文本安全性。

虽然我们通常不会反对谷物,但我们更愿意使用内置的支持来使用SOAP Web服务,而不是像以前的开发人员那样滚动我们自己的解决方案。

我们已经有了一些问题,例如未能生成我们已经破解的临时类。

不幸的是,我们现在停止发送一个成功的SOAP请求。

,当我们提出一个要求是抛出的异常:

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

挖越深,实际的回应如下:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> 
    <env:Header /> 
    <env:Body> 
     <env:Fault xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> 
     <faultcode xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">wsse:FailedCheck</faultcode> 
     <faultstring>Expired message.</faultstring> 
     </env:Fault> 
    </env:Body> 
</env:Envelope> 

这似乎是“签名或解密无效“。使用其他开发人员的一揽子解决方案,具有相同的凭据按预期工作。

为什么它会在这里失败,我们能做些什么来解决它? 是否有可能不诉诸自己的要求和响应(甚至推荐?)服务?

http://schemas.xmlsoap.org/specs/ws-security/ws-security.htm

我们已经使用了WSDL,从Lumesse提供:

https://api3.lumesse-talenthub.com/CareerPortal/SOAP/FoAdvert?WSDL

端点我们打:

https://api3.lumesse-talenthub.com/CareerPortal/SOAP/FoAdvert?api_key=xxx

这里是我们到目前为止的代码,严重依据With C#, WCF SOAP consumer that uses WSSE plain text authentication? - 看起来像是同样的问题。

Correct way communicate WSSE Usernametoken for SOAP webservice具有相同的问题,但答案是我们将绑定详细信息存储在web.config中。

using (LumesseSoapTest.FoAdvert.FoAdvertWebServiceClient client = new LumesseSoapTest.FoAdvert.FoAdvertWebServiceClient()) 
{ 
    client.ClientCredentials.UserName.UserName = "xxxx"; 

    client.ClientCredentials.UserName.Password = "xxxx"; 

    var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); 

    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; 

    binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; 

    client.Endpoint.Binding = binding; 

    var response = client.getAdvertisements(new LumesseSoapTest.FoAdvert.getAdvertisements()); 
} 

请求示例Lumesse预期,从之前的开发者家庭推出的解决方案的一部分采取 - 按预期工作:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.mrted.com/"> 
    <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" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
      <wsse:UsernameToken wsu:Id="UsernameToken-11"> 
       <wsse:Username>xxxx</wsse:Username> 
       <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"> 
        xxxx 
       </wsse:Password> 
       <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">5Xhsv3Yp2l1xGpL3pNYy6A== 
       </wsse:Nonce> 
       <wsu:Created>2012-06-22T09:07:26.631Z</wsu:Created> 
      </wsse:UsernameToken> 
     </wsse:Security> 
    </soapenv:Header> 
    <soapenv:Body> 
     <getAdvertisements xmlns="http://ws.mrted.com/"> 
      <firstResult>0</firstResult> 
      <maxResults>0</maxResults> 
     </getAdvertisements> 
    </soapenv:Body> 
</soapenv:Envelope> 

例的要求,我们正在发送:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
    <s:Header> 
     <ActivityId CorrelationId="d309ce44-ed91-4314-87ee-e3abee4f531e" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">dd9a8c26-e673-464d-87e4-5cb8b76989c3</ActivityId> 
     <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
      <u:Timestamp u:Id="_0"> 
       <u:Created>2014-09-30T16:15:47.426Z</u:Created> 
       <u:Expires>2014-09-30T16:20:47.426Z</u:Expires> 
      </u:Timestamp> 
      <o:UsernameToken u:Id="uuid-c3275c63-6d98-4ae3-a7a7-afe314d23d6c-3"> 
       <o:Username>xxxx</o:Username> 
       <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxxx</o:Password> 
      </o:UsernameToken> 
     </o:Security> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     <getAdvertisements xmlns="http://ws.mrted.com/"> 
      <firstResult>0</firstResult> 
      <maxResults>0</maxResults> 
     </getAdvertisements> 
    </s:Body> 
</s:Envelope> 

任何帮助将不胜感激。

更新

右键,使用该黑客一起XML,我可以从API响应。

我只是没有线索如何从我们的请求中产生此。再次,任何帮助将不胜感激。

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> 
    <s:Header> 
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
     <o:UsernameToken u:Id="UsernameToken-11"> 
     <o:Username>xxx</o:Username> 
     <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">xxx 
     </o:Password> 
     <o:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"> 
      5Xhsv3Yp2l1xGpL3pNYy6A== 
     </o:Nonce> 
     <o:Created>2012-06-22T09:07:26.631Z</o:Created> 
     </o:UsernameToken> 
    </o:Security> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <getAdvertisements xmlns="http://ws.mrted.com/"><firstResult>0</firstResult><maxResults>10</maxResults> 
    </getAdvertisements> 
    </s:Body> 
</s:Envelope> 

更新2(得到它的工作!)

最后,经过约9小时,我们已经得到了地方。我将在此留给任何其他与Lumesse(或其他类似的Java Web服务)合作的不幸的人。

上面发送的XML的主要问题是Security节点下的Timestamp节点。它会处理的无关的Nonce节点,大概是因为它不是安全节点下的第一个节点?谁知道(这实际上是我用SOAP/WCF以任何形式的第一次经历!)。因此,时间戳节点需要去。如果您需要使用像basicHttpBinding 或wsHttpBinding这样的标准绑定,则需要创建一个自定义绑定。这里有一个例子,模仿basicHttpBinding的,很显然,从​​

实例配置采取:

<customBinding> 
    <binding name="MyBinding"> 
    <security authenticationMode="UserNameOverTransport" includeTimestamp="false" /> 
    <textMessageEncoding messageVersion="Soap11" /> 
    <httpsTransport maxReceivedMessageSize="26214400" /> 
    </binding> 
</customBinding> 

然后,只需拨打服务和会,传递凭证(您也许可以在web.config中存储这些并肩以上,但如果我知道如何,我现在是该死的)。

using (LumesseSoapTest.FoAdvert.FoAdvertWebServiceClient client = new LumesseSoapTest.FoAdvert.FoAdvertWebServiceClient()) 
{ 
    client.ClientCredentials.UserName.UserName = "xxxx"; 

    client.ClientCredentials.UserName.Password = "xxxx"; 

    foreach (var ad in response.advertisementResult.advertisements) 
    { 
    @ad.jobTitle <br /> 
    } 

}再次

感谢。

+0

我没有在WSDL中看到安全信息,您确定这是正确的URL吗? WSDL应该有一个(对于ws- *)。另外,在你的家庭卷起的例子中,你将getAdvertisements结束标记定义为,是第二个结束括号吗?另外你的第二个例子有一个AcctivityId节点,你的home-rolled示例没有。 – 2014-09-30 17:29:13

+0

这当然是 - 愚蠢的问题 - 我认为这将是一个相当大的问题?更新了主页滚动的示例请求XML。我刚刚尝试将SOAP XML手动推送到没有ActivityId节点的Lumesse,不会影响结果('wsse:FailedCheck') - 尽管它稍后可能会发生! – milquetoastable 2014-09-30 17:35:21

+0

更新 - 刚刚尝试在UsernameToken节点中输入Nonce和Created节点。没有喜悦,同样的错误。 – milquetoastable 2014-09-30 17:42:43

回答