By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,490 Members | 3,266 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,490 IT Pros & Developers. It's quick & easy.

Use SSL to talk to fedex

P: n/a
I am trying to implement talk directly to the fedex servers so i can use
there online services. I need to first establish an SSL connection then
send some information to the fedex servers and wait for and process the
response.

I have seen some code that will allow me to recieve info over ssl and some
that will allow me to send info over ssl but not both.
Thanks in advance for any help,
~Logan

I have attached the VB sample code fedex provides
----------
Private Sub Command1_Click()

qq$ = Chr$(34) 'The " character

'DNS name of FedEx server

'contact FedEx for correct server name and port

SvcAddr = "SSLserver.fedex.com"

SvcPort = 8000

SvcName = "/GatewayDC"

' Set proxy - Examine this method to set specific proxy address

WinHttpReq.SetProxy HTTPREQUEST_PROXYSETTING_DIRECT

'Specify https for Secure Sockets

RequestHeader = "https://" + SvcAddr + ":" + SvcPort + SvcName

' Open an HTTP Request.

WinHttpReq.Open "POST", RequestHeader, False

' Substitute your Company name for MyApplication

WinHttpReq.SetRequestHeader "User-Agent", "MyApplication"

WinHttpReq.SetRequestHeader "Content-type", "image/gif"

WinHttpReq.SetRequestHeader "Accept", "image/gif, image/x-xbitmap,

image/jpeg, image/pjpeg, */*"

'A simple 402 tracking transaction

APITrans = "0," + qq$ + "402" + qq$ + "29," + qq$ + "821343443862" + qq$

+ "99," + qq$ + qq$

' Send the HTTP Request.

WinHttpReq.Send APITrans

' Put status and content type into status text box.

Text1.Text = WinHttpReq.Status & " - " & WinHttpReq.StatusText

Text2.Text = WinHttpReq.ResponseText

End Sub

--------------------------

Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Logan,

You can do this easily in .NET. You want to use the HttpWebRequest and
HttpWebResponse classes in the System.Net namespace. Here is that sample,
translated into .NET:

// Create a Uri builder.
UriBuilder uriBuilder = new UriBuilder("https", SvcAddr, SvcPort,
GatewayDC);

// Get the uri.
Uri uri = uriBuilder.Uri;

// Create an HttpWebRequest.
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);

// Set the method.
request.Method = "POST";

// Set the user agent.
request.UserAgent = "MyApplication";

// Set the content type.
request.ContentType = "image/gif";

// Set the accept header.
request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";

// The qq.
string qq = new String(new char[]{Convert.ToChar(34)});

// The body of the request.
// You could use a StringBuilder here as well, better for lots of appending
operations to strings.
string body = "0," + qq + "402" + qq + "29," + qq + "821343443862" + qq +
"99," + qq + qq;

// Convert to bytes.
byte[] bytes = Encoding.ASCII.GetBytes(body);

// Set the content length.
request.ContentLength = bytes.Length;

// Now send the text, get the request stream.
Stream stream = request.GetRequestStream();

// Write the bytes to the stream.
stream.Write(bytes, 0, bytes.Length);

// Now get the response.
HttpWebResponse response = (HttpWebResponse) request.GetResponse();

// You can now get the status through the Status property on
// the HttpWebResponse, and get the text of the response by calling
// GetResponseStream and getting the bytes and decoding them into unicode.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Logan" <lo***@globalweb.net> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
I am trying to implement talk directly to the fedex servers so i can use
there online services. I need to first establish an SSL connection then
send some information to the fedex servers and wait for and process the
response.

I have seen some code that will allow me to recieve info over ssl and some
that will allow me to send info over ssl but not both.
Thanks in advance for any help,
~Logan

I have attached the VB sample code fedex provides
----------
Private Sub Command1_Click()

qq$ = Chr$(34) 'The " character

'DNS name of FedEx server

'contact FedEx for correct server name and port

SvcAddr = "SSLserver.fedex.com"

SvcPort = 8000

SvcName = "/GatewayDC"

' Set proxy - Examine this method to set specific proxy address

WinHttpReq.SetProxy HTTPREQUEST_PROXYSETTING_DIRECT

'Specify https for Secure Sockets

RequestHeader = "https://" + SvcAddr + ":" + SvcPort + SvcName

' Open an HTTP Request.

WinHttpReq.Open "POST", RequestHeader, False

' Substitute your Company name for MyApplication

WinHttpReq.SetRequestHeader "User-Agent", "MyApplication"

WinHttpReq.SetRequestHeader "Content-type", "image/gif"

WinHttpReq.SetRequestHeader "Accept", "image/gif, image/x-xbitmap,

image/jpeg, image/pjpeg, */*"

'A simple 402 tracking transaction

APITrans = "0," + qq$ + "402" + qq$ + "29," + qq$ + "821343443862" + qq$

+ "99," + qq$ + qq$

' Send the HTTP Request.

WinHttpReq.Send APITrans

' Put status and content type into status text box.

Text1.Text = WinHttpReq.Status & " - " & WinHttpReq.StatusText

Text2.Text = WinHttpReq.ResponseText

End Sub

--------------------------

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.