Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. package pl.edu.zut.wi.edi.soapws.client;
  2.  
  3. import static java.lang.System.out;
  4.  
  5. import java.io.IOException;
  6.  
  7. import javax.xml.parsers.ParserConfigurationException;
  8. import javax.xml.transform.TransformerException;
  9.  
  10. import org.xml.sax.SAXException;
  11. /**
  12. *
  13. * wsimport -p pl.edu.zut.wi.edi.soapws.client -keep http://localhost:8888/wus?wsdl
  14. *
  15. */
  16. public class WUClient {
  17.  
  18. WUServiceImplService service = new WUServiceImplService( );
  19. WUService port = service.getWUServiceImplPort( );
  20.  
  21. public static void main( String[ ] args ) {
  22. WUClient wuc = new WUClient( );
  23. try {
  24. wuc.start2( );
  25. } catch( Exception ex ) {
  26. ex.printStackTrace( );
  27. }
  28. }
  29.  
  30. private void start1( ) throws SAXException, ParserConfigurationException, IOException, TransformerException {
  31. /* wczytaj i waliduj dokument XML */
  32. WUXMLBuilder wuxmlb = new WUXMLBuilder( );
  33. wuxmlb.validateXML( "PIT37.xml" );
  34. out.println( "[INFO] Dokument XML jest zgodny ze schematem XSD:" );
  35. out.println( new String( wuxmlb.getDocumentBytes( ) ) );
  36.  
  37. /* wysłanie dokumentu XML */
  38. out.println( "\n[INFO] Wysyłam dokument XML do WUService." );
  39. String secret = port.send( wuxmlb.getDocumentBytes( ) );
  40. out.println( "[INFO] Secret = {" + secret + "}" );
  41.  
  42. /* pobierz status przetwarzania dokumentu */
  43. out.println( "\n[INFO] Pobieram status dokumentu XML secret = {" + secret + "}" );
  44. int status = port.status( secret );
  45. out.println( "[INFO] Odebrałem Status = {" + status + "}" );
  46. }
  47.  
  48.  
  49. private void start2( ) throws SAXException, ParserConfigurationException, IOException, TransformerException {
  50. /* wczytaj i waliduj dokument XML */
  51. WUXMLBuilder wuxmlb = new WUXMLBuilder( );
  52. wuxmlb.validateXML( "PIT37.xml" );
  53. out.println( "[INFO] Dokument XML jest zgodny ze schematem XSD:" );
  54. out.println( wuxmlb.getDocumentString( ) );
  55.  
  56. /* wysłanie dokumentu XML */
  57. out.println( "\n[INFO] Wysyłam dokument XML do WUService." );
  58. String secret = port.send( wuxmlb.getDocumentBytes( ) );
  59. out.println( "[INFO] Secret = {" + secret + "}" );
  60.  
  61. /* pobierz status przetwarzania dokumentu */
  62. out.println( "\n[INFO] Pobieram status dokumentu XML secret = {" + secret + "}" );
  63. int status = port.status( secret );
  64. out.println( "[INFO] Odebrałem Status = {" + status + "}" );
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement