logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Publish CXF WS using Domain instead of "localhost"
Author
neoxmu



Joined: 01 Aug 2012
Posts: 2
Location: CN

PostPosted: Wed 01 Aug '12 17:32    Post subject: Publish CXF WS using Domain instead of "localhost" Reply with quote

Publish CXF Webservice using Domain Name instead of "localhost"

How to Publish CXF Webservice using Domain Name instead of "localhost"
example:
I want to Change String address = "http://localhost:9000/helloWorld"; TO
String address = "http://neoxmu.kmdns.net:9000/helloWorld";
but java throws exceptions:java.net.BindException: Cannot assign requested address: bind

DeployHelloWorldService.java
Code:
package com.neoxmu.service.deploy;

import java.io.*;
import java.net.*;

import javax.xml.ws.Endpoint;
import com.neoxmu.service.HelloWorldService;

public class DeployHelloWorldService {
   
   public static void deployService() {
      System.out.println("Server start!!!");
      HelloWorldService service = new HelloWorldService();
      String address = "http://localhost:9000/helloWorld";      
      Endpoint.publish(address, service);
   }
   
   public static void main(String[] args) throws InterruptedException, IOException {
      deployService();
      System.out.println("server ready !!!");
      Thread.sleep(1000 * 1200);
      System.out.println("server exiting");
      System.exit(0);
   }



HelloWorldService.java
Code:
package com.neoxmu.service;

import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

@WebService
@SOAPBinding(style = Style.RPC)
public class HelloWorldService
{   
   public String sayHello(@WebParam(name = "name") String name)
   {
      return name + " say: Hello World ";
   }
}


HelloWorldServiceClient.java

Code:
package com.neoxmu.client;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import com.neoxmu.service.IHelloWorldService;

public class HelloWorldServiceClient {
   
   public static void main(String[] args) throws IOException {
      JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
      factory.setServiceClass(IHelloWorldService.class);
      factory.setAddress("http://localhost:9000/helloWorld");      
      //factory.setAddress("http://neoxmu.kmdns.net:9000/helloWorld");            
      IHelloWorldService service = (IHelloWorldService) factory.create();
      System.out.println("[result]" + service.sayHello("neoxmu"));
   }   

Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Thu 02 Aug '12 9:56    Post subject: Reply with quote

does neoxmu.kmdns.net resolve to 127.0.0.1? if not, the script may can't connect might through a firewall or such.
Back to top
neoxmu



Joined: 01 Aug 2012
Posts: 2
Location: CN

PostPosted: Thu 02 Aug '12 14:54    Post subject: Reply with quote

James Blond wrote:
does neoxmu.kmdns.net resolve to 127.0.0.1? if not, the script may can't connect might through a firewall or such.

neoxmu.kmdns.net has been registered in the DNS Server,it links to the ip '121.204.187.188' and the firewall has been shutdown.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Tue 07 Aug '12 10:12    Post subject: Reply with quote

If that service you communicate with if on the same machine, why not using localhost?
You could change the DNS on the server itself using the hosts file. Than neoxmu.kmdns.ne could point to 127.0.0.1 on that server.
Back to top


Reply to topic   Topic: Publish CXF WS using Domain instead of "localhost" View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner