Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I translated a IEndPointBehavior Class from c# to VB
Pretty sure I got it right, but haven't been able to test it yet.

I just want to hook up the bahavior to the SendAndCommit so I can test the outcome of the HMAC Calculation, and see if my translation works correctly, but I can't find the ServiceSoapClient called before SendAndCommit.

I'm not sure if it's part of the Service Reference, or if it's part of .Net.
I thought perhaps that I have to create my own endpoint, and wrap it in a service host, So I experimented with writing a serivce endpoint, but I think I'm on the wrong track here, and need to go back to the ServiceSoapClient.

Sample Code in c#:
var client = new ServiceSoapClient(new BasicHttpBinding(BasicHttpSecurityMode.Transport),
   new EndpointAddress(_isDemo ? TestUrl : ProdUrl));
   client.ChannelFactory.Endpoint.Behaviors.Add(new HmacHeaderBehaivour(_hmac,_keyId));

   TransactionResult result = client.SendAndCommit(new Transaction


What I wrote, based on research
Dim m_endPoint_Url As String = My.Resources.endPoint_Url_Demo
Dim hmac_behavior As New HMAC_Header_Behavior(m_key, m_keyID)
Dim svcCcontractDesc As New ContractDescription("firstData_G4_V14")
Dim svcEndPoint As New ServiceEndpoint(svcCcontractDesc)
Dim svcBinding As New BasicHttpBinding()

svcEndPoint.Address = New EndpointAddress(New Uri(m_endPoint_Url))
svcEndPoint.Behaviors.Add(hmac_behavior)
svcEndPoint.Binding = svcBinding

Dim ws As com.firstdata.globalgatewaye4.V14.Service
Dim rxn As com.firstdata.globalgatewaye4.V14.TransactionResult

Using host As New ServiceHost(hmac_behavior)
    With host
      .Open()

      'Transmit the Card Authorization Request
      ws = New com.firstdata.globalgatewaye4.V14.Service
      rxn = New com.firstdata.globalgatewaye4.V14.TransactionResult
      rxn = ws.SendAndCommit(txn)

     .Close()
   End With
End Using
Posted
Updated 7-Jan-15 8:24am
v3

1 solution

jkirkerx wrote

I translated a IEndPointBehavior Class from c# to VB
No need to translate it manually and be unsure if it was correct or not. You can do it automatically, online and off-line. While on-line could be unsuccessful in some cases, you can use off-line method based on Reflector or, better, open-source ILSpy which translates the whole project and guarantees correct result. The quality of the code on output is also very good.

For further detail, please see my past answer: Code Interpretation, C# to VB.NET[^].

—SA
 
Share this answer
 
Comments
jkirkerx 6-Jan-15 18:39pm    
I'm trying to hook the behavior that I already translated to the code example above,
SendAndCommit(txn)

I just can't figure out how to add the behavior to SendAndCommit(txn)

I did a poor job in explaining, probably because I didn't want to say the wrong thing.
Sergey Alexandrovich Kryukov 6-Jan-15 19:18pm    
Do you already have working C# project? If so, why wasting time on manual translation? What if you translated it incorrectly?
Another option: why not using the class library assembly build from C# code by including it in your solution and referencing it in your VB.NET project?
—SA
jkirkerx 6-Jan-15 19:29pm    
I just wanted to hook it up, so I can test it. Yes I do have 1 or 2 lines incorrect, in which I am now going to use your solution, but you were just 1 step ahead of me on this, and 1 hour as well.
Slow down dude, and at least give me some time to move.


This is what I translated.
http://www.karpach.com/first-data-wcf-e4-integration.htm
Sergey Alexandrovich Kryukov 6-Jan-15 19:40pm    
Nobody rushed you. "Dude"...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900