digitalwise
asked on
C# script to Coldfusion
We are connecting to a new vendor's webservice and were given sample code in c# which is a little rusty for me.
I am trying to convert it over to CF since that is what the client's platform is. I thought creating an array would work but I am clearly missing something big.
I know I don't have c set - OrderInitialize didn't seem to be a c# command...
var broker = new Broker(); var c = broker.OrderInitialize();
c.RequiredInformation.ApplicationId = “applicationID”;
c.RequiredInformation.ApplicationPassword = “applicationPwd”;
c.RequiredInformation.TransPaymentType = “CC-PURCHASE”;
c.RequiredInformation.Total = 20.00
c.OrderDetails.OrderId = order.OrderId.ToString();
response.redirect(https://url/Payment.aspx”?tokenId=”+ broker.GetToken(c));
I am trying to convert it over to CF since that is what the client's platform is. I thought creating an array would work but I am clearly missing something big.
<cfset objToken = {
c.RequiredInformation.ApplicationId = "#application.yorkaid#",
c.RequiredInformation.ApplicationPassword = "#application.yorkaad#",
c.RequiredInformation.TransPaymentType = "CC-PURCHASE",
c.RequiredInformation.Total = qryOrder.OrderTotal,
c.OrderDetails.OrderId = Session.Registration.OrderID
} />
<CFLOCATION URL="url/Payment.aspx?tokenID=#objToken.GetToken(c)#" addtoken="no">
I know I don't have c set - OrderInitialize didn't seem to be a c# command...
ASKER
I was trying to redo it all in cfml but I can use CFOBJECT to create a class but I am not sure what else i need to do...
Well it sounds like this "Broker" is a custom class. Without seeing the actual code for that class, I don't know whether it's simpler to load the DLL and create instances of it -OR- rewrite the C# logic in CFML. All depends on what Broker.GetToken() and Broker.OrderInitialize() actually do (which I can't see :-)
ASKER
So they provide me with a URL that they have labeled as Reference XML Webservice (QA). Would a cfhttp call to that somehow start the ability to consume their webservice? I guess I am just used to web services where I call it, send my information and then use their response. This is package up my stuff and send it to their website in a redirect where the customer does their stuff and then comes back to us doesn't make sense.
Ooh.. if it's a web service, maybe those classes are created automatically from the WSDL, sort of like what createObject("webservice") does.
If you try calling the web service with ?wsdl and dump the object, do you see any methods like OrderInitialize and GetToken()?
<cfscript>
obj = createObject("webservice", "https://theurl?wsdl");
writeDump(obj);
</cfscript>
EDIT:
Yes, most likely. However, I'd do the above first to confirm. Then figure out what info to pass and how.
If you try calling the web service with ?wsdl and dump the object, do you see any methods like OrderInitialize and GetToken()?
<cfscript>
obj = createObject("webservice",
writeDump(obj);
</cfscript>
EDIT:
cfhttp call to that somehow start the ability to consume their webservice
Yes, most likely. However, I'd do the above first to confirm. Then figure out what info to pass and how.
ASKER
Nope - that doesn't work - says unable to read so clearly not set up as wsdl... I will wait until the dev guy is back inhouse tomorrow to see what the heck he missed sending me
Sounds like a good idea.
ASKER
So by accident I clicked in a link the reference guide and was brought to a page about creating the service.
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe https://theirurl/Broker.svc?wsdl
You can also access the service description as a single file:
https://theirURL/Broker.svc?singleWsdl (which brings up XML)
Neither of which actually works with the createobject
then
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe https://theirurl/Broker.svc?wsdl
You can also access the service description as a single file:
https://theirURL/Broker.svc?singleWsdl (which brings up XML)
Neither of which actually works with the createobject
then
class Test
{
static void Main()
{
PaymentServiceClient client = new PaymentServiceClient();
// Use the 'client' variable to call operations on the service.
// Always close the client.
client.Close();
}
}
EDIT:
1. What's the exact error message from createObject?
2. Can you view it in a browser?
https://theirurl/Broker.svc?wsdl
3. You could also try using SOAPUI, to generate the xml needed to call it from cfhttp
1. What's the exact error message from createObject?
2. Can you view it in a browser?
https://theirurl/Broker.svc?wsdl
3. You could also try using SOAPUI, to generate the xml needed to call it from cfhttp
4. If you're using CF11 I believe it defaults to Axis 2. Try setting the call to use Axis 1:
<cfscript>
// only refresh once, ie refreshwsdl=true
obj = createObject("webservice"
, "https://theirurl/Broker.svc?wsdl"
, {wsversion="1",refreshwsdl ="true"});
writeDump(obj);
</cfscript>
<cfscript>
// only refresh once, ie refreshwsdl=true
obj = createObject("webservice"
, "https://theirurl/Broker.svc?wsdl"
, {wsversion="1",refreshwsdl
writeDump(obj);
</cfscript>
ASKER
1. So apparently it is a CF8 issue because locally on CF11 it works (yes - I know - we are in the process of upgrading) - we have been using CFX_HTTP5 in the meantime... The error on CF8 is Error: javax.net.ssl.SSLPeerUnver ifiedExcep tion: peer not authenticated. It does work on CF11... So will I be able to use CFX_HTTP5 to work around this? I guess i will need to play with it.
2. Yes
2. Yes
If it's just a standard web service, almost certainly yes. Download SoapUI and plug in the URL to see what XML you need to supply.
If it works under CF11, looking at the cfdump might help as well, since it's sometimes a little easier to follow than web service XML.
If it works under CF11, looking at the cfdump might help as well, since it's sometimes a little easier to follow than web service XML.
>> javax.net.ssl.SSLPeerUnver ifiedExcep tion: peer not authenticated
... though since it's an SSL problem, I'd try importing the certificate into the keystore. See if that resolves it. Then you could use cfhttp or createObject("webservice") . Since it sounds like you probably can use CFX_HTTP5 either way, it's not critical, but it certainly wouldn't hurt to have the other options.
... though since it's an SSL problem, I'd try importing the certificate into the keystore. See if that resolves it. Then you could use cfhttp or createObject("webservice")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I imported the cert to the keystore and get Variable WRITEDUMP is undefined. So no more issue with the connection but...
ASKER
So am I wrapping that in cfscript?? Sorry - not completely clear on the steps...
Well it should always be defined, unless it's throwing a different error now, one not displayed on screen. Check the error logs.
For grins, try the above under CF11, just to verify orderInitialize() does work with createObject.
Don't forget to try SoapUI too. If there's a problem with the web service under CF8, you may end up having to go the SOAP + cfhttp route.
For grins, try the above under CF11, just to verify orderInitialize() does work with createObject.
Don't forget to try SoapUI too. If there's a problem with the web service under CF8, you may end up having to go the SOAP + cfhttp route.
ASKER
order = ws.orderInitialize();
writeDump( order );
token = ws.getToken(order);
give me ws is not defined
writeDump( order );
token = ws.getToken(order);
give me ws is not defined
Sorry, "ws" is a shortcut for whatever variable name you used for the web service object, ie
ws = createObject("webservice", "https://theirurl/Broker.svc?wsdl");
ws = createObject("webservice",
ASKER
I got it. I am getting bad credentials but it is working on cf11 do you know why I get
Variable WRITEDUMP is undefined on cf8?
Variable WRITEDUMP is undefined on cf8?
Not sure. Could be a fatal exception. Those don't always display on screen. Often they're only in the log files, so I'd check there first.
ASKER
Ah no - WriteDump - was CF9 and above. But I am in business now... Thank you so much!
ASKER
Awesome as always!!
Oops, my bad. Missed the part about it being Variable WRITEDUMP undefined. Glad it worked out, despite that :-)
Looks like they're creating an instance of some custom class, ie "Broker", and OrderInitialize() is a method of that class. Are you also creating an instance of the custom class in CF, or are you reconstructing all of the logic in cfml?