Last active
March 3, 2018 14:37
-
-
Save hinunbi/2d785dd156153d55fd00 to your computer and use it in GitHub Desktop.
마이크로 SOAP 웹 서비스 서버
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
마이크로 SOAP 웹 서비스 서버 인용 |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:camel="http://camel.apache.org/schema/spring" | |
xmlns:cxf="http://camel.apache.org/schema/cxf" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd | |
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd"> | |
… |
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
<!-- 웹 서비스와 웹 URL 지정 --> | |
<cxf:cxfEndpoint id="PaymentServiceEndpoint" | |
serviceClass="com.brm.ws.payment.Payment" | |
address="http://localhost:9090/paymentService" /> | |
<bean id="paymentService" class="com.brm.ws.payment.DefaultPayment" /> |
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
<!-- 카멜 라우팅 정의 --> | |
<camelContext xmlns="http://camel.apache.org/schema/spring"> | |
<!-- 이체 서비스 예외를 SOAP fault message로 지정 --> | |
<route handleFault="true"> | |
<!-- 이체 웹 서비스 인터페이스 엔드포인트 --> | |
<from uri="cxf:bean:PaymentServiceEndpoint" /> | |
<!-- 이체 서비스 구현 엔드포인트 --> | |
<to uri="bean:paymentService" /> | |
</route> | |
</camelContext> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:camel="http://camel.apache.org/schema/spring" | |
xmlns:cxf="http://camel.apache.org/schema/cxf" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd | |
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd"> | |
<!-- 웹 서비스와 웹 URL 지정 --> | |
<cxf:cxfEndpoint id="PaymentServiceEndpoint" | |
serviceClass="com.brm.ws.payment.Payment" | |
address="http://localhost:9090/paymentService" /> | |
<!-- 서비스 빈 --> | |
<bean id="paymentService" class="com.brm.ws.payment.DefaultPayment" /> | |
<!-- 카멜 라우팅 정의 --> | |
<camelContext xmlns="http://camel.apache.org/schema/spring"> | |
<!-- 이체 서비스 예외를 SOAP fault message로 지정 --> | |
<route handleFault="true"> | |
<!-- 이체 웹 서비스 인터페이스 엔드포인트 --> | |
<from uri="cxf:bean:PaymentServiceEndpoint" /> | |
<!-- 이체 서비스 구현 엔드포인트 --> | |
<to uri="bean:paymentService" /> | |
</route> | |
</camelContext> | |
</beans> |
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
prompt> mvn camel:run |
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 com.brm.ws.payment; | |
import com.brm.ws.payment.types.Fault; | |
import com.brm.ws.payment.types.TransferRequest; | |
import com.brm.ws.payment.types.TransferResponse; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
public class DefaultPayment implements Payment { | |
private static final Logger logger = LoggerFactory.getLogger(DefaultPayment.class); | |
private long MAX_TRANSFER_AMOUNT = 1000000; | |
@Override | |
public TransferResponse transferFunds(TransferRequest request) throws TransferException { | |
TransferResponse response = new TransferResponse(); | |
if (request.getAmount() > MAX_TRANSFER_AMOUNT) { | |
String reason = String.format("이체 한도 금액 초과: 이체 요청 금액(%d)", request.getAmount()); | |
Fault fault = new Fault(); | |
fault.setReason(reason); | |
TransferException faultMessage = new TransferException("이체 오류", fault); | |
logger.warn(reason, faultMessage); | |
throw faultMessage; | |
} else { | |
response.setReply("OK"); | |
} | |
return response; | |
} | |
} |
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 com.brm.ws.payment.types; | |
public class Fault { | |
private String reason; | |
public String getReason() { | |
return reason; | |
} | |
public void setReason(String value) { | |
this.reason = value; | |
} | |
} |
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
prompt> mvn archetype:generate -DarchetypeGroupId=org.apache.camel.archetypes -DarchetypeArtifactId=camel-archetype-spring -DarchetypeVersion=2.13.2 -DarchetypeRepository=https://repository.apache.org/content/groups/public | |
... | |
Define value for property 'groupId': : com.brm | |
Define value for property 'artifactId': : mwss-example | |
Define value for property 'version': 1.0-SNAPSHOT: : | |
Define value for property 'package': com.brm: : com.brm.ws |
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 com.brm.ws.payment; | |
import com.brm.ws.payment.types.TransferRequest; | |
import com.brm.ws.payment.types.TransferResponse; | |
public interface Payment { | |
public TransferResponse transferFunds(TransferRequest payload) throws TransferException; | |
} |
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
... | |
<!-- mwss-example --> | |
<dependency> | |
<groupId>org.apache.camel</groupId> | |
<artifactId>camel-cxf</artifactId> | |
<version>2.13.2</version> | |
</dependency> | |
<dependency> | |
<groupId>org.apache.cxf</groupId> | |
<artifactId>cxf-rt-transports-http-jetty</artifactId> | |
<version>2.7.11</version> | |
</dependency> | |
<dependency> | |
<groupId>org.apache.commons</groupId> | |
<artifactId>commons-lang3</artifactId> | |
<version>3.3.2</version> | |
</dependency> | |
</dependencies> |
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
[main] MainSupport INFO Apache Camel 2.13.2 starting | |
[main] SpringCamelContext INFO Apache Camel 2.13.2 (CamelContext: camel-1) is starting | |
[main] ManagedManagementStrategy INFO JMX is enabled | |
[main] DefaultTypeConverter INFO Loaded 193 type converters | |
[main] SpringCamelContext INFO AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance. | |
[main] SpringCamelContext INFO StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html | |
[main] ReflectionServiceFactoryBean INFO Creating Service {http://payment.ws.brm.com/}Payment from class com.brm.ws.payment.Payment | |
[main] ServerImpl INFO Setting the server's publish address to be http://localhost:9090/paymentService | |
[main] Server INFO jetty-8.1.14.v20131031 | |
[main] AbstractConnector INFO Started SelectChannelConnector@localhost:9090 | |
[main] SpringCamelContext INFO Route: route1 started and consuming from: Endpoint[cxf://bean:PaymentServiceEndpoint] | |
[main] SpringCamelContext INFO Total 1 routes, of which 1 is started. | |
[main] SpringCamelContext INFO Apache Camel 2.13.2 (CamelContext: camel-1) started in 0.991 seconds | |
[main] SpringCamelContext INFO Apache Camel 2.13.2 (CamelContext: camel-2) is starting | |
[main] ManagedManagementStrategy INFO JMX is enabled | |
[main] DefaultTypeConverter INFO Loaded 193 type converters | |
[main] SpringCamelContext INFO AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance. | |
[main] SpringCamelContext INFO StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html | |
[main] ReflectionServiceFactoryBean INFO Creating Service {http://payment.ws.brm.com/}Payment from class com.brm.ws.payment.Payment | |
[main] SpringCamelContext INFO Route: route2 started and consuming from: Endpoint[direct://payment] | |
[main] SpringCamelContext INFO Total 1 routes, of which 1 is started. | |
[main] SpringCamelContext INFO Apache Camel 2.13.2 (CamelContext: camel-2) started in 0.103 seconds |
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 com.brm.ws.payment; | |
import com.brm.ws.payment.types.Fault; | |
@SuppressWarnings("serial") | |
public class TransferException extends Exception { | |
private Fault fault; | |
public TransferException() { | |
super(); | |
fault = new Fault(); | |
fault.setReason("No message"); | |
} | |
public TransferException(String message) { | |
super(message); | |
} | |
public TransferException(String message, Throwable cause) { | |
super(message, cause); | |
} | |
public TransferException(String message, Fault fault) { | |
super(message); | |
this.fault = fault; | |
} | |
public TransferException(String message, Fault fault, Throwable cause) { | |
super(message, cause); | |
this.fault = fault; | |
} | |
public Fault getFault() { | |
return fault; | |
} | |
} |
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 com.brm.ws.payment.types; | |
public class TransferRequest { | |
private String bank; | |
private String from; | |
private String to; | |
private long amount; | |
public String getBank() { | |
return bank; | |
} | |
public void setBank(String bank) { | |
this.bank = bank; | |
} | |
public String getFrom() { | |
return from; | |
} | |
public void setFrom(String from) { | |
this.from = from; | |
} | |
public String getTo() { | |
return to; | |
} | |
public void setTo(String to) { | |
this.to = to; | |
} | |
public long getAmount() { | |
return amount; | |
} | |
public void setAmount(long amount) { | |
this.amount = amount; | |
} | |
} |
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 com.brm.ws.payment.types; | |
public class TransferResponse { | |
private String reply; | |
public String getReply() { | |
return reply; | |
} | |
public void setReply(String reply) { | |
this.reply = reply; | |
} | |
} |
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
http://localhost:9090/paymentService?wsdl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment