• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Invoking Web Services

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);}
}
}
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic