You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Dr. Laurence Leff" <D-...@wiu.edu> on 2007/08/09 22:42:39 UTC
File Transmission WebService
I am having trouble with my first web service.
(I was able to get the CalcClient and Calculator.jws from the Axis
User's Guide working. I used this as a guide to writing my own service.)
Here is my Client and T.jws file:
import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import java.net.URL;
public class TTest {
public static void main (String args[]) {
try {
URL url = new URL ("http://toolman.wiu.edu:1800/axis/T.jws");
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(url);
call.setOperationName("M");
call.addParameter("q",XMLType.XSD_STRING,ParameterMode.IN);
call.addParameter("y",XMLType.XSD_INT,ParameterMode.IN);
call.setReturnType(XMLType.XSD_INT);
Object [] O ;
O = new Object[2];
O[0] = "abcdef";
O[1] = new Integer(7);
Object ret = call.invoke (O);
if (ret instanceof String) {
System.out.println ("ret is " + ret);
}
else {
Integer r = (Integer) ret;
System.out.println (r.intValue());
}
}
.... catches deleted for brevity ...
class T {
public int M (String q, int y) {
int result;
result = y + q.length();
return result;
}
}
here is the automatically generated wsdl at
http://toolman.wiu.edu:1800/axis/T.jws?wsdl
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://toolman.wiu.edu:1800/axis/T.jws" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://toolman.wiu.edu:1800/axis/T.jws" xmlns:intf="http://toolman.wiu.edu:1800/axis/T.jws" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <!--
WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)
-->
- <wsdl:message name="MRequest">
<wsdl:part name="q" type="xsd:string" />
<wsdl:part name="y" type="xsd:int" />
</wsdl:message>
- <wsdl:message name="MResponse">
<wsdl:part name="MReturn" type="xsd:int" />
</wsdl:message>
- <wsdl:portType name="T">
- <wsdl:operation name="M" parameterOrder="q y">
<wsdl:input message="impl:MRequest" name="MRequest" />
<wsdl:output message="impl:MResponse" name="MResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="TSoapBinding" type="impl:T">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="M">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="MRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded" />
</wsdl:input>
- <wsdl:output name="MResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://toolman.wiu.edu:1800/axis/T.jws" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="TService">
- <wsdl:port binding="impl:TSoapBinding" name="T">
<wsdlsoap:address location="http://toolman.wiu.edu:1800/axis/T.jws" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
This is what happens when I run it:
@toolman#/home/leffstudent/axis >java TTest
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system properly.
Remote Exception
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.IllegalAccessException: Class org.apache.axis.providers.java.JavaProvider can not access a member of class T with modifiers ""
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:toolman
java.lang.IllegalAccessException: Class org.apache.axis.providers.java.JavaProvider can not access a member of class T with modifiers ""
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at TTest.main(TTest.java:29)
java.lang.IllegalAccessException: Class org.apache.axis.providers.java.JavaProvider can not access a member of class T with modifiers ""
@toolman#/home/leffstudent/axis >exit
Dr. Laurence Leff, Associate Professor of Computer Science, Western Illinois University
309 367 0787 Fax 309 298 2302
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org