Web service call works in Dev but not in Production?

I have a section of code I am running which makes a call to a few methods made available through a web service.

The code runs fine in my local machine dev environment.

Then I push the same code up to our test web server and it will not run.  I get the following:


method where exception was raised:  Process_Click -- Campus_Webstore.com.elementexpress.testtransaction.Express (0) - Campus_Webstore.com.elementexpress.testtransaction.Application (1) - Campus_Webstore.com.elementexpress.testtransaction.Credentials (2) - Campus_Webstore.com.elementexpress.testtransaction.Card (3) - Campus_Webstore.com.elementexpress.testtransaction.Terminal (4) - Campus_Webstore.com.elementexpress.testtransaction.Transaction (5) - Campus_Webstore.com.elementexpress.testtransaction.Response (6) - Campus_Webstore.com.elementexpress.testtransaction.TransactionSetupMethod (7) - Campus_Webstore.com.elementexpress.testtransaction.TransactionSetup (8) - Campus_Webstore.com.elementexpress.testtransaction.PaymentAccount (9) - System.Exception (10) - System.Exception (11) -  -- 

MESSAGE:  Unable to connect to the remote server

STACK TRACE:     at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at Campus_Webstore.com.elementexpress.testtransaction.Express.TransactionSetup(Credentials credentials, Application application, Terminal terminal, Transaction transaction, TransactionSetup transactionSetup1, Address address, PaymentAccount paymentAccount, ExtendedParameters[] extendedParameters)
   at Campus_Webstore.WebForm4.Process_Click(Object sender, EventArgs e)

HELP LINK:  

SOURCE:  System

TARGET SITE NAME:  GetRequestStream

INNER EXCEPTION MESSAGE:  A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.120.157.10:80

INNER EXCEPTION STACK TRACE:     at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

INNER EXCEPTION HELP LINK:  

INNER EXCEPTION TARGET SITE NAME:  DoConnect

ENTIRE EXCEPTION TO STRING:  System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.120.157.10:80
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at Campus_Webstore.com.elementexpress.testtransaction.Express.TransactionSetup(Credentials credentials, Application application, Terminal terminal, Transaction transaction, TransactionSetup transactionSetup1, Address address, PaymentAccount paymentAccount, ExtendedParameters[] extendedParameters)
   at Campus_Webstore.WebForm4.Process_Click(Object sender, EventArgs e)

Open in new window




I just need some help on the troubleshooting.


Remember, this code works in Dev.
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
Gary DavisDir Internet SvcsCommented:
Basically, the error is a failure in the Connect to the endpoint (Url). If this is the client attempting to call the web service, the remote web service's Url may be incorrectly set (look at the Url property of the web service, it may still be set to the dev machine).

If the problem is the web service itself calling another web service, a similar case exists.

You can set the web service's Url property in code or in the definition of the web reference. The Url may be set as dynamic or static. If dynamic, it will be set in the config file.

Gary Davis
0
 
Tom KnowltonWeb developerAuthor Commented:
If I connected to the webservice on my Dev machine, then pushed the code to the testing web server, is there anything I am supposed to do so the webservice will work in testing as well?
0
 
Saqib KhanSenior DeveloperCommented:
what I do is... i use wsdl.exe utility within Visual Studio tools and create myself an proxy class. then you can simply put this proxy class into your project and then use it by its local reference (instead of relying on a remote end point reference in your project).

Google wsdl.exe for samples.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Tom KnowltonWeb developerAuthor Commented:
Just to be clear...I am not writing web services I am consuming 3rd party web services.

So the URL to the web service is the same whether I am in dev or testing.  That's the rub.... they web service call works fine in dev but pukes in the testing environment.
0
 
Tom KnowltonWeb developerAuthor Commented:
Here is my code that calls the webservice.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Campus_Webstore;
using Campus_Webstore.com;
using Campus_Webstore.com.elementexpress.testtransaction;


namespace Campus_Webstore
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {




            //sample data
            //http://www.localhost.com/WebForm4.aspx
            //?HostedPaymentStatus=Complete
            //&TransactionSetupID=D3BB1DC4-61E5-4916-9CD1-A89891F00637
            //&ServicesID=2784138
            //&ExpressResponseCode=0
            //&ExpressResponseMessage=PaymentAccount+created
            //&PaymentAccountID=3B461203-E1DC-4E6F-A45A-116DA47F10A6
            //&LastFour=6781
            //&ValidationCode=C4B4B89DFFDB4994
        }

        protected void Process_Click(object sender, EventArgs e)
        {
            GlobalMethods.SendEmailMessage("beginning of process click", "begin", false, "");

            Express express = new Express();
            Application application = new Application();
            Credentials credentials = new Credentials();
            Card card = new Card();
            Terminal terminal = new Terminal();
            Transaction transaction = new Transaction();
            Response response = new Response();

            //Setup the Application, Credential, Terminal
            //Transaction, and Card objects
            application.ApplicationID = "930";
            application.ApplicationName = "TCS";
            application.ApplicationVersion = "1";
            credentials.AccountID = "1000842";
            credentials.AccountToken = "397D5620BED0DF8276879058FD0B1438220032C6069392BDA278EE08D3B0D20D6ACC7C01";
            credentials.AcceptorID = "3928907";
            terminal.TerminalID = "01";
            terminal.CardholderPresentCode = CardholderPresentCode.Present;
            terminal.CardInputCode = CardInputCode.ManualKeyedMagstripeFailure;
            terminal.TerminalCapabilityCode = TerminalCapabilityCode.MagstripeReader;
            terminal.TerminalEnvironmentCode = TerminalEnvironmentCode.LocalAttended;
            terminal.CardPresentCode = CardPresentCode.Present;
            terminal.MotoECICode = MotoECICode.NotUsed;
            transaction.MarketCode = MarketCode.Retail;
            transaction.TransactionAmount = "6.54";
            //card.CardNumber = "5499990123456781";
            //card.CardNumber = "5499990123456718";
            //card.ExpirationMonth = "09";
            //card.ExpirationYear = "08";

            //Output returned values to the Response object
            //response = express.CreditCardSale(credentials, application, terminal, card, transaction, 
            //null, null);
            TransactionSetupMethod tsm = new TransactionSetupMethod();

            TransactionSetup ts = new TransactionSetup();

            ts.ReturnURL = "http://www." + HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]) + ".com/WebForm4.aspx";
            ts.TransactionSetupMethod = TransactionSetupMethod.PaymentAccountCreate;
            ts.Embedded = BooleanType.True;

            PaymentAccount pa = new PaymentAccount();

            pa.PaymentAccountReferenceNumber = "1000842";


            tsm = TransactionSetupMethod.PaymentAccountCreate;

        

            try
            {
                GlobalMethods.SendEmailMessage("before call to trans setup", "", false, "");
                response = express.TransactionSetup(credentials, application, terminal, transaction, ts, null, pa, null);
                GlobalMethods.SendEmailMessage("after call to trans setup", "", false, "");
            }
            catch (Exception eeex)
            {
                GlobalMethods.SendEmailMessage("ERROR in trans setup call", GlobalMethods.GetDetailedExceptionInfo(eeex), false, "");
            }

            
            GlobalMethods.SendEmailMessage("express trans", "ExpressMessage=" + response.ExpressResponseMessage + "\n HostMessage=" + response.HostResponseMessage, false, "");


            GlobalMethods.SendEmailMessage("express trans id", response.Transaction.TransactionID, false, "");

            try
            {
                GlobalMethods.SendEmailMessage("before call to trans setup", "", false, "");
                Response.Redirect("https://testtransaction.hostedpayments.com/?TransactionSetupID=" + response.TransactionSetup.TransactionSetupID); 
                GlobalMethods.SendEmailMessage("after call to trans setup", "", false, "");
            }
            catch (Exception eee)
            {
                GlobalMethods.SendEmailMessage("ERROR", eee.Message.ToString(), false, "");
            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect(TextBox8.Text); 
        }
    
    }
}

Open in new window

0
 
Saqib KhanSenior DeveloperCommented:
Right, but did you add any reference to your website? reference of your webservice? if you did then probably this is the issue its working on dev bu tnot local.

my solution above was to replace adding "web reference" and indtead create a proxy class:
http://www.techrepublic.com/article/consume-a-web-service-in-a-net-app/5768122
0
 
Tom KnowltonWeb developerAuthor Commented:
I will do my best to follow your suggestions, but a few concerns:

1)  The article is 6 years old  (I'm using VS 2010).
2)  This is a lot of hassle for a web service to function in both dev and testing.

I am still not sure why a Web Reference (which is what I did) is not sufficient.
0
 
Tom KnowltonWeb developerAuthor Commented:
I am leaving work, but I'll be back on again in about 16 hours.
0
 
Gary DavisDir Internet SvcsCommented:
If you added a web reference to your project, that should be sufficient.

Your code then instantiates the web service then calls the web service passing whatever parameters it needs and you get the results.

  response = express.TransactionSetup(credentials, ...);

So the question is why the test server unable to connect to the url. If you can remote-desktop to your server and then run a browser with the url of the wsdl, you may see (blocked, firewalled, credential issues, etc). If it is a DotNet web service, you can try going to the asmx and possibly use the proxy to test it.

The error you are trying to solve is Unable to connect to the remote server so this looks like DNS. If you were able to connect, you'd get an HTTP error (400, 404, 500, etc).

Gary


0
 
Saqib KhanSenior DeveloperCommented:
I know, i remember having the same issue with adding web reference, its just the way I do my project now, i just find it easier to create a proxy class(myClass.vb), add it into app_code folder and then simply take it from there. if you know how to get to the wsdl file of your web service you should be golden.

Article above it pretty old, here is how to do it with VS 2005, but the concept it prettyy much same.
http://jlab.calumet.purdue.edu/theGateway/v2/0/doc/Instructions/ProxyClassInstructionsVS2005.htm
0
 
Tom KnowltonWeb developerAuthor Commented:
https://testtransaction.elementexpress.com/express.asmx

works in my dev machine browser.



does NOT work from the testing webserver.
0
 
Tom KnowltonWeb developerAuthor Commented:
I still do not understand why it does not work on the testing webserver.
0
 
Gary DavisDir Internet SvcsCommented:
Can you go to the same asmx url on your testing webserver? Remote-desktop to it if possible. If not, write a little webpage that does an http request to that url and check its response (you should receive the same thing you see when you enter the url on your browser.

If it fails, is it because you can't resolve the DNS name (testtransactionelementexpress.com)? There seems to be a blockage somewhere.

Gary
0
 
Tom KnowltonWeb developerAuthor Commented:
How can I hunt down WHERE / WHY it is being blocked?

Where / how is this sort of thing allowed / disallowed?
0
 
Tom KnowltonWeb developerAuthor Commented:
thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.