java.net.MalformedURLException: Invalid address. Endpoint address cannot be null.
2014-09-06 22:00
435 查看
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService
public interface HelloWorld {
String sayHello(@WebParam(name="username")String username);
}
import javax.jws.WebService;
@WebService(serviceName="HelloWorld")
public class HelloWorldImpl implements HelloWorld {
@Override
public String sayHello(String username) {
return "Hello:"+username;
}
}
import javax.xml.ws.Endpoint;
public class Server {
/**
* @param args
*/
public static void main(String[] args) {
HelloWorld hello=new HelloWorldImpl();
String address="http://localhost:8081/ws/HelloWorldService";
Endpoint.publish(address, hello);
System.out.println("Servet start...");
}
}
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;
public class Client {
private static final QName SERVICE_NAME=new QName(
"http://endpoint.cxf.webservice.test/",//xmlns:tns="http://endpoint.cxf.webservice.test/"
"HelloWorld"//<wsdl:binding name="helloWorldServiceSoapBinding" type="tns:HelloWorldServiceInf">
);
private static final QName PORT_NAME=new QName(
"http://endpoint.cxf.webservice.test/",//xmlns:tns="http://endpoint.cxf.webservice.test/"
"HelloWorldImplPort"//<wsdl:port binding="tns:helloWorldServiceSoapBinding" name="HelloWorldServiceImplPort">
);
public static void main(String[] args) {
String endPointAddress="http://localhost:8081/ws/HelloWorldService";
Service service=Service.create(SERVICE_NAME);
service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endPointAddress);
HelloWorld inf=service.getPort(HelloWorld.class);
System.out.println(inf.sayHello("张三"));
}
}
----------------------------------------------------------------
执行Client报异常:java.net.MalformedURLException: Invalid address. Endpoint address cannot be null.
解决方法:
HelloWorld inf=service.getPort(HelloWorld.class);--------------->HelloWorld inf=service.getPort(PORT_NAME, HelloWorld.class);
import javax.jws.WebService;
@WebService
public interface HelloWorld {
String sayHello(@WebParam(name="username")String username);
}
import javax.jws.WebService;
@WebService(serviceName="HelloWorld")
public class HelloWorldImpl implements HelloWorld {
@Override
public String sayHello(String username) {
return "Hello:"+username;
}
}
import javax.xml.ws.Endpoint;
public class Server {
/**
* @param args
*/
public static void main(String[] args) {
HelloWorld hello=new HelloWorldImpl();
String address="http://localhost:8081/ws/HelloWorldService";
Endpoint.publish(address, hello);
System.out.println("Servet start...");
}
}
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;
public class Client {
private static final QName SERVICE_NAME=new QName(
"http://endpoint.cxf.webservice.test/",//xmlns:tns="http://endpoint.cxf.webservice.test/"
"HelloWorld"//<wsdl:binding name="helloWorldServiceSoapBinding" type="tns:HelloWorldServiceInf">
);
private static final QName PORT_NAME=new QName(
"http://endpoint.cxf.webservice.test/",//xmlns:tns="http://endpoint.cxf.webservice.test/"
"HelloWorldImplPort"//<wsdl:port binding="tns:helloWorldServiceSoapBinding" name="HelloWorldServiceImplPort">
);
public static void main(String[] args) {
String endPointAddress="http://localhost:8081/ws/HelloWorldService";
Service service=Service.create(SERVICE_NAME);
service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endPointAddress);
HelloWorld inf=service.getPort(HelloWorld.class);
System.out.println(inf.sayHello("张三"));
}
}
----------------------------------------------------------------
执行Client报异常:java.net.MalformedURLException: Invalid address. Endpoint address cannot be null.
解决方法:
HelloWorld inf=service.getPort(HelloWorld.class);--------------->HelloWorld inf=service.getPort(PORT_NAME, HelloWorld.class);
相关文章推荐
- java.lang.ClassCastException: net.sf.json.JSONNull cannot be cast to net.sf.json.JSONObject
- java.lang.IllegalArgumentException: Resources cannot be null
- java.lang.IllegalArgumentException: The path of an ForwardConfig cannot be null
- SSH 框架集 java.lang.IllegalArgumentException: node to traverse cannot be null!
- java hibernate 中"node to traverse cannot be null"错误解决办法
- java.lang.IllegalArgumentException: node to traverse cannot be null!
- java.lang.IllegalArgumentException: node to traverse cannot be null!
- java.net.BindException: Cannot assign requested address
- java hibernate 中"node to traverse cannot be null"错误解决
- tomcat启动不了——Error initializing endpoint——java.net.BindException: Address already in use: JVM_Bind <n
- java.net.BindException: Cannot assign requested address: JVM_Bind
- java.lang.IllegalArgumentException: Resources cannot be null
- 关于Strust的异常信息:java.lang.IllegalArgumentException: Resources cannot be null.
- java.net.BindException: Cannot assign requested address: Cannot bind问题解决
- java.lang.IllegalArgumentException: node to traverse cannot be null! 处理方法
- asp.net 异常:Message="Value cannot be null.\r\nParameter name: g"
- java.net.BindException: Cannot assign requested address
- java.lang.IllegalArgumentException: node to traverse cannot be null!
- ASP.NET报错——Master Page frameworkName: Value cannot be null error
- tomcat启动报错:java.net.BindException: Address already in use: JVM_Bind<null>:8080