Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Groovy
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h1>Introduction</h1> <table class="wysiwyg-macro" data-macro-name="unmigrated-inline-wiki-markup" data-macro-parameters="atlassian-macro-output-type=BLOCK" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e3VubWlncmF0ZWQtaW5saW5lLXdpa2ktbWFya3VwOmF0bGFzc2lhbi1tYWNyby1vdXRwdXQtdHlwZT1CTE9DS30&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>{link:SOAP|http://www.w3.org/TR/soap/}{link}</pre></td></tr></table> <p> 은 분산분배 환경에서 구조적 데이터를 주고 받기 위한 lightweight protocol이다. Goovy는 SOAP서버나 SOAP서버로 부터 리모트 Call을 만들 수 있게 해주는 <table class="wysiwyg-macro" data-macro-name="unmigrated-inline-wiki-markup" data-macro-parameters="atlassian-macro-output-type=BLOCK" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e3VubWlncmF0ZWQtaW5saW5lLXdpa2ktbWFya3VwOmF0bGFzc2lhbi1tYWNyby1vdXRwdXQtdHlwZT1CTE9DS30&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>{link:Xfire |http://xfire.codehaus.org}{link}</pre></td></tr></table><br /> 기반으로 SOAP을 구현했다.<br /> <br class="atl-forced-newline" /></p> <h1>Installation</h1> <p><table class="wysiwyg-macro" data-macro-name="excerpt" data-macro-parameters="atlassian-macro-output-type=BLOCK" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2V4Y2VycHQ6YXRsYXNzaWFuLW1hY3JvLW91dHB1dC10eXBlPUJMT0NLfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><table class="wysiwyg-macro" data-macro-name="unmigrated-wiki-markup" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e3VubWlncmF0ZWQtd2lraS1tYXJrdXB9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>&nbsp;$ {user.home} /.groovy/lib안에 [이 jar |http://dist.codehaus.org/groovy/jars/groovysoap-all-jsr06-0.1.jar]파일을 다운로드 받아야 만한다. 이 jar 파일은 [groovy-1.0-JSR-06|http://dist.codehaus.org/groovy/distributions/groovy-1.0-jsr-06.zip]이 요구된다. </pre></td></tr></table></td></tr></table> <br class="atl-forced-newline" /> <br class="atl-forced-newline" /></p> <h1>Getting Started</h1> <h2>The Server</h2> <p>Groovy class나 script를 사용해서 웹서비스를 개발할 수 있다. 두개의 groovy파일이 웹서비스를 작성한 것이다.</p> <ol> <li>MathService.groovy <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> public class MathService { double add(double arg0, double arg1) { return (arg0 + arg1) } double square(double arg0) { return (arg0 * arg0) } } </pre></td></tr></table></li> <li>Groovy어디서나 사용할 수 있다. <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> double add(double arg0, double arg1) { return (arg0 + arg1) } double square(double arg0) { return (arg0 * arg0) } </pre></td></tr></table></li> <li>쉬운부분이라 코멘트를 필요없다. <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import groovy.net.soap.SoapServer def server = new SoapServer("localhost", 6980) server.setNode("MathService") server.start() </pre></td></tr></table> That's all !</li> </ol> <h2>The Client</h2> <ol> <li>Oh ... 두줄 정도면 테스트가 가능하다. <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import groovy.net.soap.SoapClient def proxy = new SoapClient("http://localhost:6980/MathServiceInterface?wsdl") def result = proxy.add(1.0, 2.0) assert (result == 3.0) result = proxy.square(3.0) assert (result == 9.0) </pre></td></tr></table></li> <li>더없다..끝이다!!</li> </ol> <h1>Custom Data Types</h1> <p>이 예제는 Groovy SOAP으로 사용자 정의 데이터 타잎을 어떻게 사용하는지를 보여준다. 이코드는 <a class="confluence-link unresolved" data-filename="custom.zip" data-linked-resource-default-alias="custom.zip" href="#">here</a>에서 다운로드 받을 수 있다.</p> <h2>The Server</h2> <p><code>PersonService.groovy</code> script는 서비스의 구현과 사용자 정의 데이터 타잎(Person)을 포함하고 있다.</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-parameters="title=PersonService.groovy" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6dGl0bGU9UGVyc29uU2VydmljZS5ncm9vdnl9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> class Person { int id String firstname String lastname } Person findPerson(int id) { return new Person(id:id, firstname:'First', lastname:'Last') </pre></td></tr></table> <p><code>Server.groovy는 이전 예제와 동일한다.</code></p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-parameters="title=Server.groovy" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6dGl0bGU9U2VydmVyLmdyb292eX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import groovy.net.soap.SoapServer; def server = new SoapServer("localhost", 6980); server.setNode("PersonService"); server.start(); </pre></td></tr></table> <p> Groovy 컴파일러로 컴파일 된 각각의 클래스들은 metaclass property가 바이트코드에 포함시켜야한다. 이 프로퍼티는 Xfire와 매핑되어지는걸 막아야만한다, 만약 그렇지 않으면 <a href="http://localhost:6980/PersonServiceInterface?wsdl">http://localhost:6980/PersonServiceInterface?wsdl</a>로 부터 WSDL 문서에 획들할때 에러가 발생한다. 이 유는 Xfire가 groovy.lang.MetaClass를 맵핑할 수 없기 때문이다. 사용자 정의 타입 매핑은 메타 클래스 속성을 무시하고 디파인 해야함 한다. (참조 : <a href="http://xfire.codehaus.org/Aegis+Binding">Aegis Binding</a>).</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-parameters="title=Person.aegis.xml" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfHRpdGxlPVBlcnNvbi5hZWdpcy54bWx9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <?xml version="1.0" encoding="UTF-8"?> <mappings xmlns:sample="http://DefaultNamespace"> <mapping name="sample:Person"> <property name="metaClass" ignore="true"/> </mapping> </mappings> </pre></td></tr></table> <p>하지만, 자바 부터 사용자 정의 데이터 타입을 컴파일 한다면 바이트 코드는 metaClass속성의 포함을 원하지 않을 것이다. 그러므로, 커스텀 맵핑을 정의할 필요가 없다.</p> <h2>The Client</h2> <table class="wysiwyg-macro" data-macro-name="code" data-macro-parameters="title=Client.groovy" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6dGl0bGU9Q2xpZW50Lmdyb292eX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import groovy.net.soap.SoapClient def proxy = new SoapClient('http://localhost:6980/PersonServiceInterface?wsdl') def person = proxy.findPerson(12) println 'Person (' + person.id + ') = ' + person.firstname + ' ' + person.lastname </pre></td></tr></table> <h1>More Information</h1> <h2>Current limitations (and workaround)</h2> <ol> <li>인증(authentication)이 없다. (see JIRA issue 1457)</li> <li>Proxy를 지원하지 않는다 (see JIRA issue 1458)</li> <li>Numeric values는 사용자 정의 데이터 타잎과 array에서는 String으로 의미되어진다.</li> <li> 사용자 정의 데이터 타잎은 현재 groovy-1.0 release에서 Grooby SOAP모듈을 사용하는 클라이언트 사이드에서 사용할 수 없다.</li> <li>It looks like the XFire dynamic client does not support complex datatypes. This may be a concern if you need for example to transfer an Image as a byte array. The workaround I use is to transform this in a String an transfer that String - As this is a bit painful I am investigating moving to the regular XFire client. Here is a little program demo-ing this (look at this "disco age" image - Is Groovy that old ?</li> </ol> <p>클라이언트 (ImageClient.groovy)</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import groovy.swing.SwingBuilder import groovy.net.soap.SoapClient import javax.swing.ImageIcon import org.apache.commons.codec.binary.Base64 proxy = new SoapClient("http://localhost:6980/ImageServiceInterface?WSDL") // get the string, transform it to a byte array and decode this array b64 = new Base64() bbytes = b64.decode(proxy.getImage().getBytes()) swing = new groovy.swing.SwingBuilder() // this is regular SwingBuilder stuff i1 = swing.label(icon:new ImageIcon(bbytes)) frame = swing.frame(title:'Groovy logo', defaultCloseOperation:javax.swing.WindowConstants.DISPOSE_ON_CLOSE) { panel(){ widget(i1) } } frame.pack() frame.show() </pre></td></tr></table> <p>Base64로 인코딩된 이미가 포함된 서버:</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import groovy.net.soap.SoapServer def server = new SoapServer("localhost", 6980) server.setNode("ImageService") server.start() </pre></td></tr></table> <p>그리고 보호와 보이지 않는 부분은 []이다.</p> <h2>Demos with public web services</h2> <p>여기 테스팅을 위한 쓸모있는 웹서비스가 있다. 쉬운 예제 중 하나는 webservicex.net.에서 제공해주는 환율을 계산해주는 것이다.<br /> 여기 서비스를 사용을 데모해주는 작은 스윙 예제가 있다. Enjoy !</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import groovy.swing.SwingBuilder import groovy.net.soap.SoapClient proxy = new SoapClient("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL") def currency = ['USD', 'EUR', 'CAD', 'GBP', 'AUD'] def rate = 0.0 swing = new SwingBuilder() refresh = swing.action( name:'Refresh', closure:this.&refreshText, mnemonic:'R' ) frame = swing.frame(title:'Currency Demo') { panel { label 'Currency rate from ' comboBox(id:'from', items:currency) label ' to ' comboBox(id:'to', items:currency) label ' is ' textField(id:'currency', columns:10, rate.toString()) button(text:'Go !', action:refresh) } } frame.pack() frame.show() def refreshText(event) { rate = proxy.ConversionRate(swing.from.getSelectedItem(), swing.to.getSelectedItem()) swing.currency.text = rate } </pre></td></tr></table> <p>결과: <img class="confluence-embedded-image image-center" src="/download/attachments/231080079/GroovySOAP.png?version=1&modificationDate=1369306387658" data-image-src="/download/attachments/231080079/GroovySOAP.png?version=1&modificationDate=1369306387658" data-linked-resource-id="231375490" data-linked-resource-type="attachment" data-linked-resource-default-alias="GroovySOAP.png" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080079" title="null > GroovySOAP.png"><br /> <br class="atl-forced-newline" /></p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced