huangzhiyong 8 rokov pred
rodič
commit
87eecf8d1f

+ 5 - 1
hos-broker/src/main/resources/application.yml

@ -80,12 +80,16 @@ spring:
  camel.gateway:
    ip: localhost
    port: 8066
eureka:
  client:
    serviceUrl:
      defaultZone: http://192.168.1.221:8761/eureka/
log:
  path: /usr/local/esb/logs/broker
  level: info
hos:
  filesystem:
    url: 127.0.0.1:9010/dfs/file
    url: http://172.19.103.57:9010/dfs/file
  arbiter:
    enable: true
    url: http://172.19.103.67:10135

+ 1 - 1
hos-broker/src/main/resources/logback-spring.xml

@ -72,7 +72,7 @@
        <logger name="org.springframework" level="WARN"/>
        <logger name="springfox.documentation" level="WARN"/>
        <root level="WARN">
        <root level="INFO">
            <appender-ref ref="file"/>
            <appender-ref ref="console"/>
        </root>

+ 13 - 1
hos-camel2/pom.xml

@ -85,10 +85,22 @@
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.camel/camel-spring-ws-starter -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-ws</artifactId>
            <artifactId>camel-spring-ws-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-cxf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>3.1.10</version>
        </dependency>
    </dependencies>
</project>

+ 1 - 2
hos-camel2/src/main/java/camel/HosCamelApplication.java

@ -2,13 +2,12 @@ package camel;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
/**
 * Basic Spring Boot application.
 */
@SpringBootApplication
@EnableEurekaClient
//@EnableEurekaClient
public class HosCamelApplication {
    public static void main(String[] args) {

+ 20 - 0
hos-camel2/src/main/java/camel/api7/processor/TestClient.java

@ -0,0 +1,20 @@
package camel.api7.processor;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/4/20.
 */
public class TestClient {
    public static void main(String args[]) throws Exception{
                 JaxWsDynamicClientFactory dcf =JaxWsDynamicClientFactory.newInstance();
                 org.apache.cxf.endpoint.Client client =dcf.createClient("http://127.0.0.1:8001/esb/ws?wsdl");
                 //getUser 为接口中定义的方法名称  张三为传递的参数   返回一个Object数组
                 Object[] objects=client.invoke("test");
                 //输出调用结果
                 System.out.println("*****"+objects[0].toString());
    }
}

+ 20 - 0
hos-camel2/src/main/java/camel/api7/processor/TestWService.java

@ -0,0 +1,20 @@
package camel.api7.processor;
import javax.jws.WebMethod;
import javax.jws.WebService;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/4/14.
 */
@WebService(name = "testWService")
public interface TestWService {
    @WebMethod
    public Object test();
    @WebMethod
    public int jian(int a, int b);
}

+ 25 - 0
hos-camel2/src/main/java/camel/api7/processor/TestWServiceImpl.java

@ -0,0 +1,25 @@
package camel.api7.processor;
import org.apache.camel.component.cxf.CxfEndpoint;
import org.springframework.stereotype.Component;
import javax.jws.WebService;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/4/20.
 */
@WebService(serviceName = "esbWService",targetNamespace="http://processor.api7.camel",endpointInterface = "camel.api7.processor.TestWService")
@Component("testWService")
public class TestWServiceImpl extends CxfEndpoint implements TestWService {
    @Override
    public Object test() {
        return "ESB 中的webservice。。。。。";
    }
    @Override
    public int jian(int a, int b) {
        return a+b;
    }
}

+ 40 - 0
hos-camel2/src/main/java/camel/api7/processor/TestWsConfig.java

@ -0,0 +1,40 @@
package camel.api7.processor;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import javax.xml.ws.Endpoint;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2017/4/20.
 */
//@Configuration
public class TestWsConfig {
    @Bean
    public ServletRegistrationBean dispatcherServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/esb/*");
    }
    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }
    @Bean
    public TestWService testWService() {
        return new TestWServiceImpl();
    }
    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), testWService());
        endpoint.publish("/ws");
        return endpoint;
    }
}

+ 43 - 0
hos-camel2/src/main/java/camel/api7/processor/ToWsProcessor.java

@ -0,0 +1,43 @@
package camel.api7.processor;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.stereotype.Component;
import javax.xml.soap.SOAPMessage;
@Component
public class ToWsProcessor implements Processor {
    public void process(final Exchange exchange) {
        SOAPMessage soapMessage = (SOAPMessage)exchange.getIn().getBody();
    }
    public void requestWs(Exchange exchange) throws Exception {
        JaxWsDynamicClientFactory dcf =JaxWsDynamicClientFactory.newInstance();
        org.apache.cxf.endpoint.Client client =dcf.createClient("http://127.0.0.1:2222/soap/ws?wsdl");
        //getUser 为接口中定义的方法名称  张三为传递的参数   返回一个Object数组
        Object[] objects=client.invoke("test");
        //输出调用结果
        System.out.println("*****"+objects[0].toString());
//        SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
//        SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody();
//        QName payloadName = new QName("http://processor.api7.camel/", "esbWService", "test");
//        SOAPBodyElement payload = body.addBodyElement(payloadName);
//        SOAPElement message = payload.addChildElement("responseType");
    }
    public void responseWs(Exchange exchange) throws Exception {
    }
}

+ 64 - 0
hos-camel2/src/main/java/camel/api7/processor/WsProcessor.java

@ -0,0 +1,64 @@
package camel.api7.processor;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.cxf.CxfPayload;
import org.apache.cxf.binding.soap.SoapHeader;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.stereotype.Component;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Source;
import java.util.List;
@Component("wsProcessor")
public class WsProcessor implements Processor {
    public void process(final Exchange exchange) throws SOAPException {
        CxfPayload<SoapHeader> payload = exchange.getIn().getBody(CxfPayload.class);
        List<Source> elements = payload.getBodySources();
        SOAPMessage soapMessage = (SOAPMessage)exchange.getIn().getBody();
        SOAPBody soapBody = soapMessage.getSOAPBody();
        String method = exchange.getIn().getHeader("operatioNname", String.class);
        if("test".equals(method))
        {
        }else {
        }
    }
    public void requestWs(Exchange exchange) throws Exception {
        JaxWsDynamicClientFactory dcf =JaxWsDynamicClientFactory.newInstance();
        org.apache.cxf.endpoint.Client client =dcf.createClient("http://127.0.0.1:2222/soap/ws?wsdl");
        //getUser 为接口中定义的方法名称  张三为传递的参数   返回一个Object数组
        Object[] objects=client.invoke("test");
        //输出调用结果
        System.out.println("*****"+objects[0].toString());
//        SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
//        SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody();
//        QName payloadName = new QName("http://processor.api7.camel/", "esbWService", "test");
//        SOAPBodyElement payload = body.addBodyElement(payloadName);
//        SOAPElement message = payload.addChildElement("responseType");
    }
    public void responseWs(Exchange exchange) throws Exception {
    }
}

+ 60 - 0
hos-camel2/src/main/java/camel/api7/route/CxfConsumerTest.java

@ -0,0 +1,60 @@
package camel.api7.route;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
@Component
public class CxfConsumerTest extends RouteBuilder {
    protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://192.168.131.101:3333/soap/ws";
    protected static final String SIMPLE_ENDPOINT_URI = "cxf:" + SIMPLE_ENDPOINT_ADDRESS
            + "?serviceClass=camel.api7.processor.TestWServiceImpl"
            + "&dataFormat=PAYLOAD";
    // START SNIPPET: example
            public void configure() {
                from(SIMPLE_ENDPOINT_URI).log("log:msg")
                .to("cxf:bean:testWService?dataFormat=CXF_MESSAGE");
            }
        };
    // END SNIPPET: example
//    @Test
//    public void testInvokingServiceFromCXFClient() throws Exception {
//        ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
//        ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
//        clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS);
//        clientBean.setServiceClass(HelloService.class);
//        clientBean.setBus(BusFactory.newInstance().createBus());
//
//        HelloService client = (HelloService) proxyFactory.create();
//
//        String result = client.echo(TEST_MESSAGE);
//        assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);
//
//        Boolean bool = client.echoBoolean(Boolean.TRUE);
//        assertNotNull("The result should not be null", bool);
//        assertEquals("We should get the echo boolean result from router ", bool.toString(), "true");
//    }
//
//    @Test
//    public void testXmlDeclaration() throws Exception {
//        String response = template.requestBody(SIMPLE_ENDPOINT_ADDRESS, ECHO_REQUEST, String.class);
//        assertTrue("Can't find the xml declaration.", response.startsWith("<?xml version='1.0' encoding="));
//    }
//
//    @Test
//    public void testPublishEndpointUrl() throws Exception {
//        String response = template.requestBody(SIMPLE_ENDPOINT_ADDRESS + "?wsdl", null, String.class);
//        assertTrue("Can't find the right service location.", response.indexOf("http://www.simple.com/services/test") > 0);
//    }

+ 2 - 0
hos-core/src/main/java/com/yihu/hos/core/datatype/ClassFileUtil.java

@ -213,6 +213,7 @@ public class ClassFileUtil {
                return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
@ -262,6 +263,7 @@ public class ClassFileUtil {
    public static String upload(String url, File file) {
        HTTPResponse response = HttpClientKit.postFile(url, "file", file.toString(), "text/plain");
        if (response.getStatusCode() != 200) {
            System.out.println("上传文件失败,status:"+response.getStatusCode()+" body: "+response.getBody());
            return null;
        }
        return response.getBody();

+ 2 - 1
hos-core/src/main/java/com/yihu/hos/core/net/IPChoiceUtils.java

@ -8,6 +8,7 @@ import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
@ -65,7 +66,7 @@ public class IPChoiceUtils {
                allIPs.add(ip);
            }
        }
        Collections.reverse(allIPs); // 倒序排列
        // 开始从可用的IP中优先选择一个IP
        // 选择规则为:首先选择一个低位的内网IP。如果内网IP无效,则依次优先选择A类、B类、C类IP
        // 开发人员可以视自己的需求对选择规则进行更改

+ 1 - 1
hos-rest/src/main/resources/config/http.properties

@ -1,5 +1,5 @@
httpUrl = https://172.19.103.221:10000/api/v1.0
httpUrl = https://172.19.103.221:10140/api/v1.0
#  http://172.19.103.73:1443/api/v1.0
#\uFFFD\uFFFDhttps://192.168.131.15:4432/api/v1.0
  #https://172.19.103.73:443/api/v1.0

+ 1 - 1
hos-rest/src/main/resources/config/sys.config.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <!--<temp_file>D:\temp</temp_file>-->
    <temp_file>D:\temp</temp_file>
    <ehr_version>
        <org_code code="jkzl">
            <version>56395d75b854</version>

+ 2 - 2
src/main/java/com/yihu/hos/system/service/FlowManager.java

@ -66,7 +66,7 @@ public class FlowManager {
        try {
            //TODO 临时文件夹
            String newFileName = className + routeId + ".java";
            String newFilePath = "D:/temp/" + newFileName;
            String newFilePath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator")  + newFileName;
            String uploadUrl = fsUrl + "/" + tempFilePath;
            byte[] content = ClassFileUtil.down(uploadUrl);
            if (content == null) {
@ -115,7 +115,7 @@ public class FlowManager {
        try {
            String newFileName = className + routeId + ".java";
            //TODO 临时文件夹设置
            String newFilePath = "D:/temp/" + newFileName;
            String newFilePath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") +  newFileName;
            String uploadUrl = fsUrl + "/" + tempFilePath;
            byte[] content = ClassFileUtil.down(uploadUrl);
            if (content == null) {

+ 4 - 2
src/main/resources/application.yml

@ -107,10 +107,12 @@ spring:
    proxy-target-class: true
hos:
  zbus:
    url: 172.17.110.202:15555
    url: 172.19.103.57:9020
  filesystem:
    url: http://172.19.103.57:9010/dfs/file
  mysql:
    filePath: /usr/local/esb/esb.sql   #租户基础表 sql文件位置
service-gateway:
  portalUrl: http://192.168.1.221:10280/api/v1.0/portal
  adminUrl: http://192.168.1.221:10000/api/v1.0/admin
  url: http://172.17.110.202:9999/api
  url: http://172.19.103.70:9999/api