������� ��������� ���������� ������������ �� �������� � �������, �� ��� �� ��
�������.
��� ���:
package com.livinge.ejbtest;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebService;
@Stateless
@WebService (serviceName="Substructor", portName="SubstructorPort")
public class SimpleServiceBean implements ServiceBean {
@WebMethod
public int substruct(int a, int b) {
return a - b;
}
}
��� ��������� ������:
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import com.livinge.ejbtest.ServiceBean;
import com.livinge.ejbtest.SimpleBean;
import com.livinge.ejbtest.SimpleServiceBean;
public class EJBTester {
static final String HOST = "localhost";
static final String PORT_TYPE = "SimpleServiceBean";
static final String SERVICE_NAME = "Substructor";
static final String SERVICE_ENDPOINT_ADDRESS = "http://" + HOST + ":8080/" +
SERVICE_NAME;
static final String NAME_SPACE = "http://ejbtest.livinge.com/";
public void runTest() throws Exception {
System.out.println("Try WSDL");
// Substruct substruct = new Substruct();
// SimpleServiceBean substr = substruct.;
// System.out.println(substruct.substr(50, 20));
URL wsdlLocation = new URL(SERVICE_ENDPOINT_ADDRESS + "/" + PORT_TYPE +
"?WSDL");
QName qname = new QName(NAME_SPACE, SERVICE_NAME);
Service service = Service.create(wsdlLocation, qname);
ServiceBean substr = service.getPort(SimpleServiceBean.class);
System.out.println(substr.substruct(50, 20));
}
public static void main(String[] args) {
try {
EJBTester cli = new EJBTester();
cli.runTest();
} catch (Exception e) {
e.printStackTrace();
}
}
��� ���������:
java.lang.IllegalArgumentException: com.livinge.ejbtest.SimpleServiceBean is
not an interface
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:362)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at
com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSSe
rviceDelegate.java:546)
at
com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java
:292)
at
com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java
:274)
at
com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java
:302)
at
com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java
:306)
at javax.xml.ws.Service.getPort(Service.java:161)
at com.livinge.ejbtester.EJBTester.runTest(EJBTester.java:45)
at com.livinge.ejbtester.EJBTester.main(EJBTester.java:55)
��: ���� Glassfish
ServiceBean substr = service.getPort(ServiceBean.class);
hrensgory
SB> From: "Sergey Bezrukov" <ad...@playa.ru>
��>> ServiceBean substr = service.getPort(SimpleServiceBean.class);
SB> ServiceBean substr = service.getPort(ServiceBean.class);
SB> hrensgory
��������. �������� ��������� ������ �������, �� ������ ����, ��� ����� ��� ��
���������������.
����