java.net.MalformedURLException when creating an URL object [Solved]
-
Hi all, I'm picking up Java for an integration project. I'm trying to utilize to a webservice from our externally hosted CRM application. I got some code from the CRM web services guide to log on to the application. However, when constructing the URL for logon purposes, the URL constructor throws the java.net.MalformedURLException. See the following line of code:
URL wsURL = new URL(pstrServer + "/Services/Integration?command=ssoitsurl&ssoid=" + pstrSSOID);
This should construct the following URL: https://abc.crmapplication.com/Services/Integration?command=ssoitsurl&ssoid=SSOID. When I remove the second query parameter (ssoid) the URL is constructed fine. Does anybody know why the construction of this URL object fails? How can I set the multiple query parameters for the URL? Thanks in advance and I'm looking forward to your reply. Kind regards, Bob Stanneveld
-
Hi all, I'm picking up Java for an integration project. I'm trying to utilize to a webservice from our externally hosted CRM application. I got some code from the CRM web services guide to log on to the application. However, when constructing the URL for logon purposes, the URL constructor throws the java.net.MalformedURLException. See the following line of code:
URL wsURL = new URL(pstrServer + "/Services/Integration?command=ssoitsurl&ssoid=" + pstrSSOID);
This should construct the following URL: https://abc.crmapplication.com/Services/Integration?command=ssoitsurl&ssoid=SSOID. When I remove the second query parameter (ssoid) the URL is constructed fine. Does anybody know why the construction of this URL object fails? How can I set the multiple query parameters for the URL? Thanks in advance and I'm looking forward to your reply. Kind regards, Bob Stanneveld
What Every Developer Should Know About URLs might be those slashes, are they converted correctly? greets Torsten
I never finish anyth...
-
Hi all, I'm picking up Java for an integration project. I'm trying to utilize to a webservice from our externally hosted CRM application. I got some code from the CRM web services guide to log on to the application. However, when constructing the URL for logon purposes, the URL constructor throws the java.net.MalformedURLException. See the following line of code:
URL wsURL = new URL(pstrServer + "/Services/Integration?command=ssoitsurl&ssoid=" + pstrSSOID);
This should construct the following URL: https://abc.crmapplication.com/Services/Integration?command=ssoitsurl&ssoid=SSOID. When I remove the second query parameter (ssoid) the URL is constructed fine. Does anybody know why the construction of this URL object fails? How can I set the multiple query parameters for the URL? Thanks in advance and I'm looking forward to your reply. Kind regards, Bob Stanneveld
-
Hi all, I'm picking up Java for an integration project. I'm trying to utilize to a webservice from our externally hosted CRM application. I got some code from the CRM web services guide to log on to the application. However, when constructing the URL for logon purposes, the URL constructor throws the java.net.MalformedURLException. See the following line of code:
URL wsURL = new URL(pstrServer + "/Services/Integration?command=ssoitsurl&ssoid=" + pstrSSOID);
This should construct the following URL: https://abc.crmapplication.com/Services/Integration?command=ssoitsurl&ssoid=SSOID. When I remove the second query parameter (ssoid) the URL is constructed fine. Does anybody know why the construction of this URL object fails? How can I set the multiple query parameters for the URL? Thanks in advance and I'm looking forward to your reply. Kind regards, Bob Stanneveld
A MalformedURLException normally includes a message to tell you what it thinks is wrong with the URL. For example, if I try to construct a URL from this string:
xyz://www.google.com
I get the following message in the MalformedURLException:
unknown protocol: xyz
What error message do you get?
-
A MalformedURLException normally includes a message to tell you what it thinks is wrong with the URL. For example, if I try to construct a URL from this string:
xyz://www.google.com
I get the following message in the MalformedURLException:
unknown protocol: xyz
What error message do you get?
Hi, Thanks for your reply. I don't get any error message... Here's the stack trace / exception printout:
Exception in component tWebServiceInput_1
java.net.MalformedURLException
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at routines.CRMLogin.logonSSO(CRMLogin.java:97)
at crmtest.testcrm_0_1.TestCRM.tWebServiceInput_1Process(TestCRM.java:338)
at crmtest.testcrm_0_1.TestCRM.runJobInTOS(TestCRM.java:632)
at crmtest.testcrm_0_1.TestCRM.main(TestCRM.java:506)The strange thing is that a bogus domain in the URL results in a correctly constructed URL object. When the correct URL is passed to the constructor (checked it with Internet Explorer), the exception gets thrown... Kind regards, Bob Stanneveld
-
Hi, Thanks for your reply. I don't get any error message... Here's the stack trace / exception printout:
Exception in component tWebServiceInput_1
java.net.MalformedURLException
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at routines.CRMLogin.logonSSO(CRMLogin.java:97)
at crmtest.testcrm_0_1.TestCRM.tWebServiceInput_1Process(TestCRM.java:338)
at crmtest.testcrm_0_1.TestCRM.runJobInTOS(TestCRM.java:632)
at crmtest.testcrm_0_1.TestCRM.main(TestCRM.java:506)The strange thing is that a bogus domain in the URL results in a correctly constructed URL object. When the correct URL is passed to the constructor (checked it with Internet Explorer), the exception gets thrown... Kind regards, Bob Stanneveld
Bob Stanneveld wrote:
When the correct URL is passed to the constructor (checked it with Internet Explorer), the exception gets thrown.
I don't think this is your problem. I have tried URLs with real and bogus domains and, as long as they are correctly formed, then there is no problem. You need to catch the exception that is being thrown and check exactly what message it is producing. Also check the validity of all your variables within your exception handler.
It's time for a new signature.
-
Hi, Thanks for your reply. I don't get any error message... Here's the stack trace / exception printout:
Exception in component tWebServiceInput_1
java.net.MalformedURLException
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at routines.CRMLogin.logonSSO(CRMLogin.java:97)
at crmtest.testcrm_0_1.TestCRM.tWebServiceInput_1Process(TestCRM.java:338)
at crmtest.testcrm_0_1.TestCRM.runJobInTOS(TestCRM.java:632)
at crmtest.testcrm_0_1.TestCRM.main(TestCRM.java:506)The strange thing is that a bogus domain in the URL results in a correctly constructed URL object. When the correct URL is passed to the constructor (checked it with Internet Explorer), the exception gets thrown... Kind regards, Bob Stanneveld
Bob Stanneveld wrote:
a bogus domain in the URL results in a correctly constructed URL object
The URL constructor does not check that the domain exists, it merely checks that the URL is properly formed according to the documented standard (whatever that happens to be).
Bob Stanneveld wrote:
When the correct URL is passed to the constructor (checked it with Internet Explorer), the exception gets thrown
Do you mean that you have checked the actual string value being passed to the URL constructor at runtime? This works for me:
String a = "https://abc.crmapplication.com";
String b = "SSOID";
URL url = new URL(a + "/Services/Integration?command=ssoitsurl&ssoid=" + b);If that exact same piece of code does not work for you, then I am at a loss to understand what is happening, I'm afraid.
-
Hi all, I'm picking up Java for an integration project. I'm trying to utilize to a webservice from our externally hosted CRM application. I got some code from the CRM web services guide to log on to the application. However, when constructing the URL for logon purposes, the URL constructor throws the java.net.MalformedURLException. See the following line of code:
URL wsURL = new URL(pstrServer + "/Services/Integration?command=ssoitsurl&ssoid=" + pstrSSOID);
This should construct the following URL: https://abc.crmapplication.com/Services/Integration?command=ssoitsurl&ssoid=SSOID. When I remove the second query parameter (ssoid) the URL is constructed fine. Does anybody know why the construction of this URL object fails? How can I set the multiple query parameters for the URL? Thanks in advance and I'm looking forward to your reply. Kind regards, Bob Stanneveld
Hi all, I'm using the Talend Open Studio ETL tool for my integration. Unfortunately, this tool doesn't have advaneced debuging facilities and I don't have access to a nice IDE. So after a couple of hours, pain and agony I discovered that the exception is thrown elsewhere in the code where a URL object is constructed with an empty string (a redirection URL should have been obtained from the reply from the server, but this is a different issue). Thank you all for your help. Perhaps I'll post another question soon :-D. Kind regards, Bob Stanneveld