Hi,
This is my web service client. But I have a strange error : The import javax.xml.rpc.namespace cannot be resolved.
But in my lib directory I have axis.jar, jaxrpc.jar and xerces.jar.
What is missing please ?
import java.net.URL;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.namespace.QName;
public class SparePartPriceServiceClient {
// Creates new HellowWorldClient
public SparePartPriceServiceClient() {
}
public static void main (String args[]) {
try {
// EndPoint URL for the SparePartPrice web service.
String endpointURL =
"http://localhost:8080/axis/services/SparePartPrice";
// Method Name to invoke for the SparePartPrice web
// service
String methodName = "getPrice";
// Create the Service call
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress (new java.net.URL (endpointURL)) ;
call.setOperationName (new
QName ("SparePartPrice",methodName)) ;
call.addParameter ("sku",XMLType.XSD_STRING,
ParameterMode.PARAM_MODE_IN);
call.setReturnType (XMLType.XSD_FLOAT);
//Setup the Parameters i.e. the Part SKU to be passed as input
//parameter to the SparePartPrice web service
Object [] params = new Object[] {"SKU-123"};
//Invoke the SparePartPrice web service
Float price = (Float) call.invoke (params);
//Print out the result
System.out.println ("The price is $" + price.floatValue());
}
catch (Exception e) {
System.out.println(e.toString());
}
}
}