Goals:
wsimport -d <class-directory> \ -s <java-directory> \ -p <package> \ http://www.xmlme.com/WSDailyXml.asmx?WSDL
Given a Service class generated by wsimport:
Service myService = new Service(); System.out.println( myService .getEndpoint() .method("arg1", "arg2"));
The setHandlerResolver registers a handler that can intercept and modify SOAP messages.
Service myService = new Service(); XmlFact.setHandlerResolver(myHandlerResolver);
public class SampleResolver implements HandlerResolver { public List<Handler> getHandlerChain(PortInfo portInfo) { List<Handler> handlerChain = new ArrayList<Handler>(); handlerChain.add(new myHandler()); return handlerChain; } }
class MyHandler implements SOAPHandler<SOAPMessageContext> { public void close(MessageContext messagecontext) { } public Set<QName> getHeaders() { // Find the header blocks that we can process return null; } public boolean handleFault(SOAPMessageContext messagecontext) { System.out.println("fault"); return true; // continue processing }
public boolean handleMessage(SOAPMessageContext messagecontext) { Boolean outbound = (Boolean)messagecontext.get( MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { System.out.println("Message to service"); } else { System.out.println("Message from service"); } return true; // continue processing } } //class
Amazon requires an application key:
This key will be disabled after the lab. You can create one for yourself after that.
Goals:
We will use Apache CXF.
This framework implements both JAX-WS (SOAP) and JAX-RS (REST).
Messages are serialized to XML through JAXB.
Services can be created Java-first or WSDL-first. We will use the Java-first way.
@WebService public interface MyCalc { public abstract int add(int a, int b); public abstract int substract(int a, int b); }
@WebService(targetNamespace="http://...", serviceName="HelloWorld") public interface MyCalc { public abstract int add(int a, int b); public abstract int substract(int a, int b); }
Style specification:
@WebService(targetNamespace="http://...", serviceName="HelloWorld") @SOAPBinding(style=Style.RPC, use=Use.ENCODED) public interface MyCalc { public abstract int add(int a, int b); public abstract int substract(int a, int b); }
public interface MyCalc { public abstract int add(int a, int b); public abstract int substract(int a, int b); @WebMethod(exclude=true) public abstract void ninja(); //Won't show up! }
public interface MyCalc { @WebMethod(operationName="plus") public abstract int add(int a, int b); @WebMethod(operationName="minus") public abstract int substract(int a, int b); }
public interface MyCalc { @RequestWrapper(localname="additionOperands", targetNamespace="http://example.org/calc/") @WebResult(name="sum") public abstract int add( @WebParam(name="operand1") int a, @WebParam(name="operand2") int b); public abstract int substract(int a, int b); }
public class Video { @XmlElement(required=true) //JAXB annotations String title; int length; ArrayList<String> Comments; } public interface SmileyVideo { public abstract ArrayList<String> findVideos( String keywords); }
ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(SmileyVideo.class); factory.setAddress("http://smileyvideo.com"); Service client = (SmileyVideo) factory.create(); ArrayList<Video> vids = client.findVideos("Bad Apple"); //etc.
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |