Can someone please tell me what I'm doing wrong?
I'm trying to put together a quick web service test just to see if I can get it to work for now.
The problem I'm having is that, as shown below, it does not work, but if I change the URL and replace "myWebsite.com" with "localhost" it works. So, I know the server side is working (I've still checked and double checked it though). But I'll need this to work through remote clients, and I just cannot get it to work.
Any help would be greatly appreciated.
package stickman.Server;
import java.net.*;
import javax.xml.namespace.*;
import javax.xml.ws.*;
import stickman.Combined.*;
public class TestApp {
public static void main(String[] args) throws Exception {
// --------------------------------------------
// changing "myWebite.com" to "localhost" works
URL url = new URL(
"http://myWebsite.com:32768/home/rhyan/workspace/Stickman/bin/stickman/Server");
// --------------------------------------------
QName qname = new QName("http://Server.stickman/","StickmanServerService");
Service service = Service.create(url, qname);
StickmanServerInterface ssi = service.getPort(StickmanServerInterface.class);
Account a = ssi.getAccount("This is a test");
System.out.println(a.getUserId());
}
}
Edit: here's the error tracking...
Exception in thread "main" com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.
java.net.ConnectException: Connection refused
java.net.ConnectException: Connection refused
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:161)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:133)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:254)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:217)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:165)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:93)
at javax.xml.ws.Service.<init>(Service.java:76)
at javax.xml.ws.Service.create(Service.java:700)
at stickman.Server.ServerTestApp.main(ServerTestApp.java:17)
Could be a DNS problem? What IP address do you resolve myWebsite.com to?
Your exception indicates that the wsdl for the service is not accessible - not the service itself. Can you confirm that the wsdl for the service is available at this location - http://myWebsite.com:32768/home/rhyan/workspace/Stickman/bin/stickman/Server, and the url in the wsdl points to a proper working endpoint.
It took 8 days of reading a plethora of stuff online before I finally found the answer to my problem through a random google search I came up with: Publishing a WS with Jax-WS Endpoint
"localhost" should be 0.0.0.0, and I totally should have known this.
Thanks to the people who tried to help.
Related
I am trying to consume below public web service using Eclipse.
http://www.webservicex.com/globalweather.asmx?wsdl
When I execute in the java client it gives the error;
java.net.ConnectException: Connection timed out: connect
Below is the simple client program;
public class ClientTest1
{
public static void main(String[] args)
{
GlobalWeatherSoapProxy obj1 = new GlobalWeatherSoapProxy();
try
{
System.out.println(obj1.getCitiesByCountry("Japan"));
}
catch(Exception e1)
{
System.out.println(+e1.getMessage());
}
}
}
However strangely this works fine when consumed through SOAP UI. Hence I assume this is something to do with Eclipse configuration.
Thank you in advance for any help.
Eclipse has nothing to do with it. Your code is executed by the JVM, even if your development environment is Eclipse. A connection time out means that your client is not able to connect with the endpoint.
You have auto-generated the client proxy in some way getting GlobalWeatherSoapProxy. This class will obtain the reference to endpoint by loading WSDL. Alternatively url can be provided by code. Review the content of that class to see how endpoint URL is loaded
You should see something like (check this full example)
URL url = new URL("http://localhost:9999/ws/hello?wsdl");
QName qname = new QName("http://ws.mkyong.com/", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);
I need to authenticate myself in Remedy. I'm following the documentation, but I still getting some errors.
https://communities.bmc.com/docs/DOC-17514
This is my code:
import com.bmc.arsys.api.ARException;
import com.bmc.arsys.api.ARServerUser;
public class Tutorial {
public static void main(String[] args) {
ARServerUser ctx = new ARServerUser();
ctx.setServer("127.0.0.1");
ctx.setUser("myusername");
ctx.setPassword("mypassword");
ctx.setPort(8080);
try {
ctx.verifyUser();
} catch (ARException e) {
System.out.println(e.getMessage());
}
}
}
I'm receiving this error:
ERROR (91): RPC call failed; 127.0.0.1:8080 can not receive ONC/RPC data
How can I fix that? I need to set the instance, like 127.0.0.1/arsys. My Remedy instance is arsys.
I can authenticate using the browser: http://127.0.0.1:8080/arsys
Thanks in advance.
is your midtier on the same server as your AR server?
if not, then You need to set the IP of your AR server instead.
Since you have mentioned that you are able to authenticate using http://127.0.0.1:8080/arsys via browser, it means that 8080 is being used by web server and AR Server can't use the same. Please provide your port number(where your AR Server is listening) in setPort(). Also try to make sure that your hostname/ip address is reachable from the machine where you are executing your program.
The setServer parameter expects the name of the ARS server, not the IP address. Here is the matching constructor signature:
ARServerUser(java.lang.String user, java.lang.String password, java.lang.String locale, java.lang.String serverName, int serverPort)
References
com.remedy.arsys.api.ARServerUser
How to authenticate in Remedy using Java
I'm having trouble with my e-mail configuration for sending e-mails using lotus notes in a java program. I know this is pretty much straight forward but i guess i'm missing something. My code is as follows;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
public class MailClass {
public void SendMail() {
SimpleEmail email = new SimpleEmail();
try {
email.setHostName("mail.smtp.host");
email.addTo("recipient#company.com");
email.setFrom("sender#agency.com");
email.setSubject("Hello World");
email.setMsg("This is a simple test of commons-email");
email.send();
} catch (EmailException ex) {
Logger.getLogger(MailClass4.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void main(String[] args) {
MailClass main = new MailClass();
main.SendMail();
}
}
I keep on getting this error
SEVERE: null
org.apache.commons.mail.EmailException: Sending the email to the following server failed : mail.smtp.host:25
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
...
Caused by: javax.mail.MessagingException: Unknown SMTP host: mail.smtp.host;
nested exception is:java.net.UnknownHostException: mail.smtp.host at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1970)
I'm guessing it's about my host but not really sure what to do about it. From my understanding your host should be your email client (ex. mail.smtp.google.com). But since this is Lotus Notes (it runs in our intranet btw) the implimentation will be different. I've seen other samples that use the "mail.smtp.host" as host but i can't get this one right....
It's my first time doing an e-mail program so i'm pretty much clueless about this.
You can use your Domino server running on your intranet as SMTP server but first you have to ask your admin if Domino has been set up to allow SMTP - and at the same time ask for the proper host name and port).
setHostName requires the hostname or IP-address of a smtp server. And the exception makes it very clear what the issue is.
Lotus Notes is basicslly just a client and has nothing to do with what you are trying to accomplish.
I have been working on this project where two modules on different machines need to be in communication through RMI.
I start both client and server modules on my laptop. RMI seems to work correctly when i am at work and connected to work network, but when i am home, connected to my home network it does not work. It says remote object could not be found.
Here is the method i use at CLIENT side to get the reference to remote object
public static MyRMIApp getRemoteApp() throws RemoteException, NotBoundException, AccessException {
Registry registry = LocateRegistry.getRegistry("localhost", 28999); // tried 127.0.0.1 instead of localhost here, still not working
MyRMIApp app = (MyRMIApp) registry.lookup("COM");
return app;
}
Digging up a bit with some debugging, when i check the object value returned from getRemoteApp method, it shows me the end point is 67.215.65.132. Which is openDNS i am using to connect to internet. Shouldn't that be 127.0.0.1 ?
Then i used my mobile internet and tried again. It seems to be working but end-point is not 127.0.0.1 again it is the address assigned to me, which is 192.168.x.x
So can anybody please tell me what is wrong i am doing here ? I really would appreciate the help.
Oh and this is the piece of code at SERVER side
//Somwhere up top
private final static MyRMIApp rmiApp = new RMIServer();
//Down below
MyRMIApp stub = (MyRMIApp) UnicastRemoteObject.exportObject(rmiApp, 0);
Registry registry = LocateRegistry.createRegistry(28999);
registry.rebind("COM", stub);
See item A.1 of the RMI FAQ: specifically, 'The appropriate workaround is to set the system property java.rmi.server.hostname when starting the server.'
I'm trying to call a web service with a Java client. The WSDL looks like this: http://pastebin.com/m13124ba
My client:
public class Client{
public static void main(java.lang.String args[]){
try{
CompileAndExecuteServiceInterfaceStub stub =
new CompileAndExecuteServiceInterfaceStub
("http://192.168.1.3:8080/axis2/services/CompileAndExecuteServiceInterface");
Compile comp = new Compile();
comp.setArgs0("Test");
comp.setArgs1("public class Test { public static void main(String[] args) { System.out.println(\"Hello\");}}");
String[] classpath = {};
comp.setArgs2(classpath);
stub.compile(comp);
} catch(Exception e){
e.printStackTrace();
}
}
}
When I run the client now the following error occurs:
org.apache.axis2.AxisFault: unknown
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:517)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:371)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at de.dax.compileandexecuteclient.CompileAndExecuteServiceInterfaceStub.compile(CompileAndExecuteServiceInterfaceStub.java:184)
at de.dax.compileandexecuteclient.Client.main(Client.java:17)</blockquote>
I tried out the business logic of the server on my local machine and there it works. The service creates files and folders. Are web services allowed to do that? I also wrote a simple "Hello World" web service and deployed it to the server. This worked fine.
When you get one of these "unknown" AxisFaults, definitely check the server log! The client-side stack trace most likely will not be detailed enough for you to track down the error.
I believe dax is indicating above that he found the NullPointerException in the more-detailed server side stack trace. It would look something like:
org.apache.axis2.AxisFault
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
[....]
Caused by: java.lang.NullPointerException
[....]
From the provided logs, I cannot determine what's wrong. Try to set the log-level of Axis2 to "debug" (see the two log-configurations in the root directory of your Axis2 installation) and check the details for the exact cause. Axis2 tends to be a bit sparse in propagating the errors coming from webservices.
The problem was that there was an NullPointerException in my service.