Forums Register Login

Invoking Web Services

+Pie Number of slices to send: Send
I want to invoke a web service using apache's WSIF (Web Services Invocation Framework). But I'm getting the error that it can't deserialize the information. Has anyone tried other mechanisms to invoke web services? Please do post some code to successfully invoke a web service using any toolkit.
My code is given below:
import javax.wsdl.*;
import javax.activation.*;
import org.apache.wsif.*;
import javax.xml.namespace.*;
import org.apache.wsif.util.*;
import org.apache.wsif.providers.*;
import org.apache.wsif.providers.soap.apachesoap.WSIFDynamicProvider_ApacheSOAP;
import java.util.*;
class a
{
public static void main(String []s){
try{
Definition def = WSIFUtils.readWSDL(null,"http://webservices.scandinavian.net/flightstatus/flightservice.asmx?WSDL");
WSIFServiceFactory sf= WSIFServiceFactory.newInstance();
WSIFPluggableProviders.overrideDefaultProvider("http://schemas.xmlsoap.org/wsdl/soap/",new WSIFDynamicProvider_ApacheSOAP());
Service service = WSIFUtils.selectService(def, null,null);
String portTypeNS = null;
String portTypeName = null;
String portName = "FlightServiceSoap";
Map portTypes = WSIFUtils.getAllItems(def, "PortType");
// Really there should be a way to specify the portType
// for now just try to find one with the portName
if (portTypes.size() > 1 && portName != null) {
for (Iterator i=portTypes.keySet().iterator(); i.hasNext(); ) {
QName qn = (QName) i.next();
if (portName.equals(qn.getLocalPart())) {
portTypeName = qn.getLocalPart();
portTypeNS = qn.getNamespaceURI();
break;
}
}
}
PortType portType = WSIFUtils.selectPortType(def, portTypeNS, portTypeName);
WSIFService sq = sf.getService(def,service,portType);
WSIFPort defPort = sq.getPort();
WSIFOperation getQ = defPort.createOperation("GetFlightStatus");
WSIFMessage inMessage = getQ.createInputMessage();
WSIFMessage outMessage = getQ.createOutputMessage();
WSIFMessage fltMessage = getQ.createFaultMessage();
inMessage.setObjectPart("parameters","GetFlightStatusSoapIn");
inMessage.setObjectPart("nFlightNo", "222");
inMessage.setObjectPart("nDayOffset", "1002");
getQ.executeRequestResponseOperation(inMessage, outMessage, fltMessage);
//outMessage.getFloatPart("value");
// fltMessage.getFloatPart("value");
}catch(Exception ex){System.out.println(ex);}
}
}
I don't always make ads but when I do they're tiny
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 652 times.
Similar Threads
wsdl not getting called
WSIFException : invoking web service mthod
Accessing webservice using dynamic proxies
WSIFException : invoking service method
STUB, Dynamic Proxy, DII
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 22:40:41.