WebService annotation is not present
gryffin Mar 18, 2010 3:42 PMI am getting an error, "com.sun.xml.internal.ws.model.RuntimeModelerException: A WebService annotation is not present on class: ags.AssetGetService", which I can't fathom.
Here's the client:
package ags
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
public class AGSClient {
public static void main(String[] args) throws MalformedURLException {
URL url = new URL("http://127.0.0.1:8080/AssetGet?wsdl");
QName qname = new QName("http://www.boeing.com/AGS/api", "AssetGetService");
Service service = Service.create(url, qname);
// ws client
AssetGetService eif = service.getPort(AssetGetService.class);
// interface
AssetGetType port = eif.getAssetGetServicePort();
AssetSelector as = new AssetSelector();
as.setAssetId("foo");
as.setOwnerAppId("bar");
System.out.println(port.assetAssociationGet(as).success); } }
The interface:
package ags;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService(name = "AssetGetType", targetNamespace = "http://www.boeing.com/AGS/api")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface AssetGetType {
@WebMethod(action = "urn:http://www.boeing.com/NLS/soap#AssetAssociationGet")
@WebResult(name = "Results", partName = "Results")
public AssetAssociationGetResults assetAssociationGet(
@WebParam(name = "Selector", partName = "Selector")
AssetSelector selector); }
And the service class.
package ags;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
@WebServiceClient(name = "AssetGetService", targetNamespace = "http://www.boeing.com/AGS/api", wsdlLocation = "http://127.0.0.1:8080/AssetGet?wsdl")
public class AssetGetService
extends Service
{
private final static URL ASSETGETSERVICE_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(ags.AssetGetService.class.getName());
static {
URL url = null;
try {
URL baseUrl;
baseUrl = ags.AssetGetService.class.getResource(".");
url = new URL(baseUrl, "http://127.0.0.1:8080/AssetGet?wsdl");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the wsdl Location: 'http://127.0.0.1:8080/AssetGet?wsdl', retrying as a local file");
logger.warning(e.getMessage());
}
ASSETGETSERVICE_WSDL_LOCATION = url;
}
public AssetGetService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName) }
public AssetGetService() {
super(ASSETGETSERVICE_WSDL_LOCATION, new QName("http://www.boeing.com/AGS/api", "AssetGetService")); }
@WebEndpoint(name = "AssetGetServicePort")
public AssetGetType getAssetGetServicePort() {
return super.getPort(new QName("http://www.boeing.com/AGS/api", "AssetGetServicePort"), AssetGetType.class); } }
Here's the wsdl:
<?xml version='1.0' encoding='UTF-8'?>
<definitions name='AssetGetService' targetNamespace='http://www.boeing.com/AGS/api' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:ns1='http://www.boeing.com/AGS/ns/Types' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://www.boeing.com/AGS/api' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<types>
<xs:schema elementFormDefault='qualified' targetNamespace='http://www.boeing.com/AGS/ns/Types' version='1.0' xmlns:ns1='http://www.boeing.com/AGS/ns/Types' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:complexType name='AssetSelector'>
<xs:sequence>
<xs:element form='qualified' name='AssetId' type='xs:string'/>
<xs:element form='qualified' name='OwnerAppId' type='xs:string'/>
</xs:sequence>
</xs:complexType>
<xs:complexType name='AssetAssociationGetResults'>
<xs:sequence>
<xs:element form='qualified' name='Success' type='xs:boolean'/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
<message name='AssetGetType_assetAssociationGetResponse'>
<part name='Results' type='ns1:AssetAssociationGetResults'></part>
</message>
<message name='AssetGetType_assetAssociationGet'>
<part name='Selector' type='ns1:AssetSelector'></part>
</message>
<portType name='AssetGetType'>
<operation name='assetAssociationGet' parameterOrder='Selector'>
<input message='tns:AssetGetType_assetAssociationGet'></input>
<output message='tns:AssetGetType_assetAssociationGetResponse'></output>
</operation>
</portType>
<binding name='AssetGetTypeBinding' type='tns:AssetGetType'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='assetAssociationGet'>
<soap:operation soapAction='urn:http://www.boeing.com/NLS/soap#AssetAssociationGet'/>
<input>
<soap:body namespace='http://www.boeing.com/NLS/api' use='literal'/>
</input>
<output>
<soap:body namespace='http://www.boeing.com/NLS/api' use='literal'/>
</output>
</operation>
</binding>
<service name='AssetGetService'>
<port binding='tns:AssetGetTypeBinding' name='AssetGetServicePort'>
<soap:address location='http://127.0.0.1:8080/AssetGet'/>
</port>
</service>
</definitions>
I'm running JBoss 5.1.0.GA on JDK6 with the latest JBossWS native release.
When I run the client, the request errors out before talking to the server:
Exception in thread "main" com.sun.xml.internal.ws.model.RuntimeModelerException: A WebService annotation is not present on class: ags.AssetGetService
at com.sun.xml.internal.ws.model.RuntimeModeler.getPortTypeName(RuntimeModeler.java:1274)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:296)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:306)
at javax.xml.ws.Service.getPort(Service.java:161)
at ags.AGSClient.main(AGSClient.java:25)
I've looked at the examples, I've looked at working services I've deployed, but I don't see the problem. This doesn't appear to be a common error, so it must be some kind of simple mistake.