Last active
August 29, 2015 14:10
-
-
Save pavelk2/d5fac56d8e9e42866cfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package client; | |
import java.util.ArrayList; | |
import java.util.List; | |
import javax.xml.ws.handler.Handler; | |
import javax.xml.ws.handler.HandlerResolver; | |
import javax.xml.ws.handler.PortInfo; | |
public class JaxWsHandlerResolver implements HandlerResolver { | |
@SuppressWarnings("rawtypes") | |
@Override | |
public List<Handler> getHandlerChain(PortInfo arg0) { | |
List<Handler> hchain = new ArrayList<Handler>(); | |
hchain.add(new JaxWsLoggingHandler()); | |
return hchain; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package client; | |
import java.io.IOException; | |
import java.util.Set; | |
import javax.xml.namespace.QName; | |
import javax.xml.soap.SOAPException; | |
import javax.xml.soap.SOAPMessage; | |
import javax.xml.ws.handler.MessageContext; | |
import javax.xml.ws.handler.soap.SOAPHandler; | |
import javax.xml.ws.handler.soap.SOAPMessageContext; | |
public class JaxWsLoggingHandler implements SOAPHandler<SOAPMessageContext> { | |
@Override | |
public void close(MessageContext arg0) { | |
} | |
@Override | |
public boolean handleFault(SOAPMessageContext arg0) { | |
SOAPMessage message = arg0.getMessage(); | |
try { | |
message.writeTo(System.out); | |
} catch (SOAPException e) { | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
return true; | |
} | |
@Override | |
public boolean handleMessage(SOAPMessageContext arg0) { | |
SOAPMessage message = arg0.getMessage(); | |
boolean isOutboundMessage = (Boolean) arg0.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); | |
if (isOutboundMessage) { | |
System.out.println("OUTBOUND MESSAGE\n"); | |
} else { | |
System.out.println("INBOUND MESSAGE\n"); | |
} | |
try { | |
message.writeTo(System.out); | |
} catch (SOAPException e) { | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
return true; | |
} | |
@Override | |
public Set<QName> getHeaders() { | |
return null; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> | |
<SOAP-ENV:Header/> | |
<S:Body> | |
<ns2:createPerson xmlns:ns2="http://ws.document.introsde/"> | |
<person> | |
<idPerson>0</idPerson> | |
<lastname>Ive</lastname> | |
<name>Jony</name> | |
</person> | |
</ns2:createPerson> | |
</S:Body> | |
</S:Envelope> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package client; | |
import java.util.List; | |
import introsde.document.ws.PeopleService; | |
import introsde.document.ws.People; | |
import introsde.document.ws.Person; | |
public class PeopleClient{ | |
public static void main(String[] args) throws Exception { | |
PeopleService service = new PeopleService(); | |
service.setHandlerResolver(new JaxWsHandlerResolver()); | |
People people = service.getPeopleImplPort(); | |
Person newPerson = new Person(); | |
newPerson.setName("Jony"); | |
newPerson.setLastname("Ive"); | |
System.out.println("person ==> "+newPerson.getName()); | |
System.out.println(people.createPerson(newPerson)); | |
//System.out.println(id); | |
//List<Person> pList = | |
//System.out.println(people.getPeopleList()); | |
//Person per = people.readPerson(id); | |
//System.out.println("Result ==> "+per); | |
//System.out.println("Result ==> "+pList); | |
//System.out.println("First Person in the list ==> "+pList.get(0).getName()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> | |
<SOAP-ENV:Header/> | |
<S:Body> | |
<ns2:createPerson xmlns:ns2="http://ws.document.introsde/"> | |
<ns2:person> | |
<idPerson>0</idPerson> | |
<lastname>Ive</lastname> | |
<name>Jony</name> | |
</ns2:person> | |
</ns2:createPerson> | |
</S:Body> | |
</S:Envelope> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment