RequestSecurityTokenResponse不会反序列化

时间:2012-05-03 20:24:09

标签: c# wcf deserialization sts-securitytokenservice servicecontract

我有一个连接到STS服务器的WCF客户端,我没有任何控制权(它是第三方PHP服务)。

经过几天的研究,我设法以一种纯粹的WCF接受的方式与服务器交谈。当然,将一些字符放到网络上会很容易,忽略所有SOAP的东西。但最后我设法猜对了每个配置参数,所以STS服务就像这样回答了我的请求

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
  <Body>
    <RequestSecurityTokenResponse xmlns="http://schemas.xmlsoap.org/ws/2005/02/trust">
      <TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</TokenType>
      <RequestedSecurityToken>
        <SecurityContextToken xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
              <Identifier>bipro:D5J9M0...</Identifier>
        </SecurityContextToken>
      </RequestedSecurityToken>
    </RequestSecurityTokenResponse>
  </Body>
</Envelope>

但是现在我无法提取标识符值。对于我的代理类(SecurityTokenServicePortTypeClient : ClientBase<SecurityTokenServicePortType>, SecurityTokenServicePortType),我尝试了所有类型的ServiceContractDataContractXmlSerialization的所有可想象的组合。但我得到的只是null

服务合同的(经过大量修改的)界面如下所示

[ServiceContract(Namespace = "http://schemas.xmlsoap.org/ws/2005/02/trust")]
public interface SecurityTokenServicePortType {
  [OperationContract(Action = "urn:RequestSecurityToken", ReplyAction = "*")]
  object RequestSecurityToken();
}

(经过大量修改的)实现类有一个像这样的方法

object SecurityTokenServicePortType.RequestSecurityToken() {
  var x = base.Channel.RequestSecurityToken();
  return x;
}

x总是null

而不是object的返回类型,它原来是RequestSecurityTokenResponse,依此类推。

几年前我遇到了与WSE相同的问题,我能够通过使用例如XmlElementAttribute的正确组合来控制反序列化过程来解决这个问题。但这一次似乎没有帮助。

感谢您的任何建议!

的Björn

0 个答案:

没有答案