2 Replies - 478 Views - Last Post: 28 December 2012 - 06:42 AM Rate Topic: -----

#1 fabian5003  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-December 12

Problem: .NET doesn't generate <Reference> tag for <Bi

Posted 27 December 2012 - 02:38 PM

Hi everyone!

I'm working on a .NET app that calls a Java Web service.

.NET is generating the <BinarySecurityToken> of the SOAP request:

<wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="CertId-82F59FC97F9B80906B13522947735311">MIIDNjCC6l...[yada, yada]</wsse:BinarySecurityToken>


But it's not generating a <Reference> tag that is needed by the server and that should look a little something like this:

<Reference URI="#CertId-82F59FC97F9B80906B13522947735311">
               <Transforms>
                  <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
               </Transforms>
               <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
               <DigestValue>wTMyZchQSJUSgFxgc0FehIrnK08=</ds:DigestValue>
            </Reference>


Note the URI attribute must have the same ID of the BinarySecurityToken object. Below is the code that's generating the SOAP request that's missing this tag.

            WSReference.RequestSoapContext.Security.Timestamp.TtlInSeconds = 60
            Dim signatureToken As X509SecurityToken = New X509SecurityToken(cert)
            requestContext.Security.Tokens.Add(signatureToken)
            Dim sig As New MessageSignature(signatureToken)
            requestContext.Security.Elements.Add(sig)



I don't know if it needs another instruction or something, I hope you guys can help me.

Is This A Good Question/Topic? 0
  • +

Replies To: Problem: .NET doesn't generate <Reference> tag for <Bi

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,501
  • Joined: 16-March 11

Re: Problem: .NET doesn't generate <Reference> tag for <Bi

Posted 27 December 2012 - 04:14 PM

Personally I've never had to work with the service you're working with. Could you maybe give a little more information as to how I can get my hands on the tools to create the necessary environment to help you out? I'm quite familiar with SOAP requests, and have had to do similar work but we did not work with a java web service as it was not needed, and we also had to use OAuth for security.
Was This Post Helpful? 1
  • +
  • -

#3 fabian5003  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-December 12

Re: Problem: .NET doesn't generate <Reference> tag for <Bi

Posted 28 December 2012 - 06:42 AM

Hi, thanks for answering my post.

This is the context of the code:

Dim WSReference As SDLService = New SDLService()
Dim requestContext As SoapContext = WSReference.RequestSoapContext
Dim responseWS As ResponseDocumentReceiptServiceDTO


Dim userNameToke As New UsernameToken(user, pwd, PasswordOption.SendPlainText)

WSReference.RequestSoapContext.Security.Timestamp.TtlInSeconds = 60


Dim signatureToken As X509SecurityToken = New X509SecurityToken(cert)
requestContext.Security.Tokens.Add(signatureToken)
Dim sig As New MessageSignature(signatureToken)
'There must be some missing line here that adds the reference
'tag for the <BinarySecurityToken> element to the SOAP request. At this moment,
'this code is generating the rest of the <Reference> tags for all the elements.
'Like for example for <Timestamp>, <UsernameToken>, etc. The only missing <Reference>
'tag is the one for <BinarySecurityToken>
requestContext.Security.Elements.Add(sig)

WSReference.ClientCertificates.Add(signatureToken.Certificate)
WSReference.RequestSoapContext.Security.Tokens.Add(userNameToke)
WSReference.SetClientCredential(signatureToken)
WSReference.Url = url


Dim WSHE As HeaderDTO = New HeaderDTO()
Dim petitionWS As RequestCreateReceiptServiceDTO = New RequestCreateReceiptServiceDTO()
petitionWS.Header = WSHE
petitionWS.Header.DepositDate = DateTime.UtcNow
petitionWS.Header.Hour = DateTime.UtcNow.ToShortTimeString
petitionWS.Header.User = "oraclell"
petitionWS.Header.DepositCode = "110011"


Dim bodyXML As New List(Of DocumentReceiptServiceDTO)
Dim bodyContent As New DocumentReceiptServiceDTO
bodyContent.CompanyId = "769879"
bodyXML.Add(bodyContent)
petitionWS.DocumentReceiptServiceDTO = bodyXML.ToArray()


responseWS = WSReference.createDeposit(petitionWS)



Below is the link to the current generated XML.
XML Generated by .NET - Pastebin


Any help will be greatly appreciated!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1