I write a java code to access(connect) intuit quickbooks using this keys
String consumerKey = "qyprdTCZTGRhIYkRPU5OeXjd7rJiMS";
String consumerSecret = "L1ek9k7zX55rVXPlj5FikHYJgCnxfWCKBtjt81Ti";
String accessToken="qyprd6GGQ9w3OfmN0tg1M5xLzWdWF9RZOaMRVkb43tXNO6kG";
String accessTokenSecret = "RMKyYmrrqQY0xem2Cxj3pQeiOJwSR3ceT90wESWH";
String companyId = "1386063640";
String appId="b7qs4z3s2p";
when i execute this i got these errors
connection refused
or
java.net.UnknownHostException: sandboxquickbooks.api.intuit.com
please any one help to getting out this isue.
Simply put, the computer does not recognize the server you re attempting to connect to. The address sandboxquickbooks.api.intuit.com is not able to be located by your computer when executing the code. Take a look at this post for a little more detail...
java.net.UnknownHostException: Invalid hostname for server: local
My guess is it is spelled wrong, or they changed the address/url.
Correct sandbox base url is - https://sandbox-quickbooks.api.intuit.com
Refer java sample app here-
https://github.com/IntuitDeveloperRelations/QuickbooksV3API-Java
Related
I am experiencing the following error and after extensive research on the matter with a few similar issues, none seem to help.
My error:
com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:121)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:142)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83)
at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at com.sun.proxy.$Proxy33.onboardPerson(Unknown Source)
at com.paychex.corp.fileloader.FileloaderMain.callWebService(FileloaderMain.java:202)
at com.paychex.corp.fileloader.FileloaderMain.main(FileloaderMain.java:104)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:411)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:525)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:208)
at sun.net.www.http.HttpClient.New(HttpClient.java:291)
at sun.net.www.http.HttpClient.New(HttpClient.java:310)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:987)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:966)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1031)
at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:109)
My client is generated from wsimport using the WSDL file that IS visible from the active service. Code connection sample: URL and service name, etc are correct, can't list for security
URL url = new URL("http://correctserviceurl?WSDL");
QName qname = new QName("http://correct servicelocation","nameofService");
CorporateEmployeeOnboardingService service = new CorporateEmployeeOnboardingService(url, qname);
//CorporateEmployeeOnboardingService service = new CorporateEmployeeOnboardingService();
CorporateEmployeeOnboardingProcess process = service.getICorporateEmployeeOnboardingProcess();
OnboardRequestType onboardRequest = new OnboardRequestType();
/**
* TESTING SECTION FOR PROCESS CALL
*/
//create necessary complex types:
GregorianCalendar gregorianCalendar = new GregorianCalendar();
DatatypeFactory datatypeFactory;
datatypeFactory = DatatypeFactory.newInstance();
XMLGregorianCalendar testDate =
datatypeFactory.newXMLGregorianCalendar(gregorianCalendar);
testDate.setYear(1991);
testDate.setMonth(4);
testDate.setDay(3);
AssignmentComplexType testAssignment = new AssignmentComplexType();
testAssignment.setHiringManagerID("123445");
//set person to send
person.setSSN("333-33-3333");
person.setFirstName("testFname");
person.setLastName("testLname");
person.setDOB(testDate);
person.setHireDate(testDate);
person.setAssignment(testAssignment);
/**
* end testing section of the person creation
*/
onboardRequest.getPerson().add(person);//add a person to the array of people for the request
ServiceResponse response = process.onboardPerson(onboardRequest);
As stated SoapUI can send this same test information and get a perfectly valid request from the service. All information the same. I have been digging around for awhile and confirmed that there is no proxy, both are same bit (32/64 in this case both 32), service name and WSDL are correct and objects are named properly, etc. I did further debugging trying to get around this awful error code that has seemingly no usable information and using wireshark compared the SoapUI request to the java request to find that SoapUI was using POST and the java client was using GET which has me leaning on this right now as the source of the generic refused connection error.
The service is using BPEL to run and was created using BPEL so all code was basically generated. I will be looking at the Get/post find as of now but wanted to get this out there as I am doubtful it could be the cause.
Any help is greatly appreciated. Let me know if I forgot any key information I might be able to share.
EDIT
I wanted to add that I am able to access the endpoint URL in the web browser from the machine that I am using to try and connect to the BPEL service. It seems the issue is solely with the client generated from the WSDL stubs I got using wsimport for the service's WSDL.
Edit 2: Development/Progress
The issue seems to be that the client is sending the response to local host even after setting up the qname to the correct address. I am now trying to figure out where this local host is being set. Any ideas on this development would be greatly appreciated.
It's been a while, but I believe this line: URL url = new URL("http://correctserviceurl?WSDL");
Needs to read: URL url = new URL("http://correctserviceurl");
K! This one was an issue with BPEL I believe. Quite frustrating. Apparently after initializing the service in the following lines:
URL url = new URL("http://serviceaddresshere?WSDL");
QName qname = new QName("http://servicelocationaddress","NameOfService");
CorporateEmployeeOnboardingService service = new CorporateEmployeeOnboardingService(url, qname);
CorporateEmployeeOnboardingProcess process = service.getICorporateEmployeeOnboardingProcess();
BPEL gets the request with the service WSDL and the CORRECT address. However, BPEL seems to think "O? you want this service, here you go I'll give you that, only the WSDL you want is wrapper, so here's the REAL WSDL." In plain english, you get back the BPEL WSDL that it thinks is for the service, and this has the Localhost address in it. Now I tried changing the address in this WSDL but BPEL through errors up the wazzoo. So the work around was adding in this line after the process variable is make: (AKA THE FIX)
((BindingProvider) process).getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY, "http://the serviceaddress");
Bassically you set the endpoint AGAIN after you make the process, because BPEL overwrites what you sent it the first time. This is of course a sort of work around, but the process now works good. If you can think of a way to bypass this work around and dynamically fix the service so we don't have to keep changing the service WSDL when we move ti to new enviornments like Dev, etc. I am all ears. Thanks and as always I will read comments for suggestions. =)
You can use bpel configuration plans to switch between environments.
Configuration plans are the recommended option to use for making composites environment specific.
Efficient use of configuration plans can greatly reduce the work required per process.
A configuration plan can be generated from the composite.xml file.
Please consider this link:
http://biemond.blogspot.com.br/2010/02/web-service-references-and-soa.html
My server is running in Tomcat. Here is my WSDL path:
http://10.99.60.52:8082/rjWebServices/wsdl/UserAuthenticationService.wsdl
SOAP address location in WSDL:
<soap:address location="http://localhost:8082/rjWebServices/services/UserAuthenticationService" />
When trying to access the service from SOAP UI, I'm getting proper response.
But when trying to create a new SoapObject in android, I'm getting InvocationTargetException.
Here is my Android Code:
String SOAP_ACTION = "http://10.99.60.52:8082/rjWebServices/services/UserAuthenticationService";
String METHOD_NAME = "PasswordValidation";
String NAMESPACE = "http://10.99.60.52:8082/rjWebServices/services/UserAuthenticationService/";
String URL = "com.retailJava.webServices.services.UserAuthenticationService";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
What am I missing or doing wrong?
My IP is: 10.99.60.52
10.0.2.2:8082 would be the solution if you are trying to run your app on the emulator on the same machine where tomcat is installed!
If you are running the app on the device make sure that your device is on the same network or you have the route to your server from your device's network.
10.x.x.x is a private network and isnt valid on the internet. Download terminal emulator app and see of you can ping your server!
String SOAP_ACTION = "http://10.99.60.52:8082/rjWebServices/services/UserAuthenticationService";
I don't think, this is your soap action.
Search operation "PasswordValidation" in your wsdl, under bindings , you can find correct soap action.
String URL = "com.retailJava.webServices.services.UserAuthenticationService";
I think here you should provide your end point url.
Can you paste rest of your code where you are calling the webservice url.
InovcationTargetException means that the method that you invoked threw an exception. To figure out what the problem is with your method itself, wrap the invoke method call around a try-catch block and log
invocationTargetException.getTargetException().
use that code
String SOAP_ACTION = "http://10.99.60.52/rjWebServices/services/UserAuthenticationService";
10.99.60.52 is your ip address..
I have been trying different ways to get data from the following link:
http://www.ensembl.org/Danio_rerio/Export/Output/Location?db=core;flank3_display=300;flank5_display=300;output=fasta;r=18:19408965-19409049;strand=feature;coding=yes;cdna=yes;peptide=yes;utr3=yes;exon=yes;intron=yes;genomic=unmasked;utr5=yes;_format=Text
Copy paste the link to a web browser works for me but I cannot get to it programmatically in java.
It seems that it doesn't follow the get protocol as the separation of parameters is not as expected.
I tried to use URL but it separates the link above into server path and query and results in HTTP 500.
I tried to use sockets but again failed.
I believe that what I need is a way to simply send the complete string unaltered and then read the result.
Any ideas?
This code reads first line from that URL successfully:
URL u = new URL("http://www.ensembl.org/Danio_rerio/Export/Output/Location?db=core;flank3_display=300;flank5_display=300;output=fasta;r=18:19408965-19409049;strand=feature;coding=yes;cdna=yes;peptide=yes;utr3=yes;exon=yes;intron=yes;genomic=unmasked;utr5=yes;_format=Text");
DataInputStream ds = new DataInputStream(u.openStream());
String s = ds.readLine();
System.out.println(s);
It prints out: >18 dna:chromosome chromosome:Zv9:18:19408665:19409349:1
I'm using Java 6. I have very less knowledge of JSP and Servlets.
I'm using the following code to get browser name in which my application is running:
String browserName = requestProvider.get().getHeader("User-Agent");
Also I'm using the following code to get IP address of the machine on which my application is running:
String ipAdd = requestProvider.get().getRemoteAddr();
In both the cases requestProvider is a reference variable of type Provider<HttpServletRequest>. And I'm assured that it is never NULL.
Now the problem is some times I get both values (browserName and ipAdd) NULL.
I've written sometimes because I don't have a test case.
So my question is, what are the cases in Java, when these values can be NULL?
What care should I take in coding to avoid this issue?
Is there any alternate way to get IP address & browser name every time?
String browserName = requestProvider.get().getHeader("User-Agent");
null means whoever sent the request didn't include a "User-Agent" header.
String ipAdd = requestProvider.get().getRemoteAddr();
is unlikely to return null under normal circumstances, but there are reports the it may do so in edge cases, like after the response has already been sent. Regardless, "get IP address of the machine on which my application is running" doesn't sound like what getRemoteAddr() is for. It's for getting the address of the most recent client or proxy that sent the request.
Is there any alternate way to get IP address & browser name every time?
No. You're entirely dependent on the behavior of the HTTP client and/or any intervening proxies to get information like this.
Try using user-agent as lowercase, because it works if we directly access from header.
String browserName = requestProvider.get().getHeader("user-agent");
alternate way to get IP address is
String ip = requestProvider.get().getHeader("True-Client-IP"); this works if we have akamai integeration.
String sourceUrlString="http://maps.googleapis.com/maps/api/geocode/xml?address="+searchWord+"&sensor=true";//searchWord-parameter to be passed
Source source=new Source(new URL(sourceUrlString));
Element alpha=source.getFirstElement("location");
String beta[]=new String[100];
String lat=alpha.getContent().getFirstElement("lat").getContent().toString();
String lng=alpha.getContent().getFirstElement("lng").getContent().toString();
THE error pointed out by google app engine is in the above bold statements it says null pointer exception but on local server it returns the value and the code works fine.
wat are the possible solution to the above problem?and as of what i have come to conclusion is google app engine does not support Http request .is it true?
You need to use URL Fetch service to issue HTTP requests and receive responses:
One example:
import urllib2
url = "http://www.google.com/"
try:
result = urllib2.urlopen(url)
doSomethingWithResult(result)
except urllib2.URLError, e:
handleError(e)