Преглед на файлове

Merge branch 'master' of http://192.168.1.220:10080/esb/esb

chenyongxing преди 8 години
родител
ревизия
8d39fa228e

+ 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>

+ 7 - 1
hos-camel2/pom.xml

@ -87,8 +87,14 @@
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-ws</artifactId>
            <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://192.168.131.101:3333/soap/ws?wsdl");
                 //getUser 为接口中定义的方法名称  张三为传递的参数   返回一个Object数组
                 Object[] objects=client.invoke("test");
                 //输出调用结果
                 System.out.println("*****"+objects[0].toString());
    }
}

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

@ -0,0 +1,21 @@
package camel.api7.processor;
import javax.jws.WebMethod;
import javax.jws.WebParam;
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 plus(@WebParam(name = "a") int a, @WebParam(name = "b") int b);
}

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

@ -0,0 +1,21 @@
package camel.api7.processor;
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")
public class TestWServiceImpl implements TestWService {
    @Override
    public Object test() {
        return "ESB 中的webservice。。。。。";
    }
    @Override
    public int plus(int a, int b) {
        return a+b;
    }
}

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

@ -0,0 +1,41 @@
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 org.springframework.context.annotation.Configuration;
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;
    }
}

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

@ -0,0 +1,118 @@
package camel.api7.processor;
import org.apache.camel.Exchange;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.stereotype.Component;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import java.util.List;
@Component("toWsProcessor")
public class ToWsProcessor {
    public SOAPMessage processSOAP(Exchange exchange) {
        // Since the Camel-CXF endpoint uses a list to store the parameters
        // and bean component uses the bodyAs expression to get the value
        // we'll need to deal with the parameters ourself
        List list = exchange.getIn().getBody(List.class);
        if (list == null) {
            System.out.println("Incoming null message detected...");
            return createDefaultSoapMessage("null");
        }
        SOAPMessage soapMessage = null;
        try {
            if (list.isEmpty()){
                soapMessage = (SOAPMessage) list.get(0);
            }
            SOAPPart sp = soapMessage.getSOAPPart();
            SOAPEnvelope se = sp.getEnvelope();
            SOAPBody sb = se.getBody();
            String requestText = sb.getFirstChild().getNextSibling().getTextContent();
            System.out.println(requestText);
            return createDefaultSoapMessage(requestText);
        } catch (Exception e) {
            e.printStackTrace();
            return createDefaultSoapMessage(e.getClass().getName());
        }
    }
    public SOAPMessage test(Exchange exchange) {
//        String wsdl = "http://127.0.0.1:8001/esb/ws?wsdl";
//        List soapMessage =  exchange.getIn().getBody(List.class);
//        if (soapMessage == null ) {
//            System.out.println("Incoming null message detected...");
//            return createDefaultSoapMessage("null");
//        }
        try {
//            String requestText = requestWs(exchange, wsdl, "test");
            return createDefaultSoapMessage(exchange.getIn().getBody().toString());
        } catch (Exception e) {
            e.printStackTrace();
            return createDefaultSoapMessage(e.getClass().getName());
        }
    }
    public SOAPMessage plus(Exchange exchange) {
        String wsdl = "http://127.0.0.1:8001/esb/ws?wsdl";
        SOAPMessage soapMessage = (SOAPMessage) exchange.getIn().getBody(List.class).get(0);
        if (soapMessage == null) {
            System.out.println("Incoming null message detected...");
            return createDefaultSoapMessage("null");
        }
        try {
            String requestText = requestWs(exchange, wsdl, "plus");
            return createDefaultSoapMessage(requestText);
        } catch (Exception e) {
            e.printStackTrace();
            return createDefaultSoapMessage(e.getClass().getName());
        }
    }
    /**
     * 请求ws
     *
     * @param exchange
     * @param method
     * @return
     * @throws Exception
     */
    public String requestWs(Exchange exchange, String wsdl, String method) throws Exception {
        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        org.apache.cxf.endpoint.Client client = dcf.createClient(wsdl);
        //getUser 为接口中定义的方法名称  张三为传递的参数   返回一个Object数组
        Object[] objects = client.invoke(method);
        //输出调用结果
        System.out.println("*****" + objects[0].toString());
        return objects[0].toString();
    }
    /**
     * 生成ws返回内容
     *
     * @param requestMessage
     * @return
     */
    public static SOAPMessage createDefaultSoapMessage(String requestMessage) {
        try {
            SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
            SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody();
            QName payloadName = new QName("http://gateway.api", "test", "ns1");
            SOAPBodyElement payload = body.addBodyElement(payloadName);
            SOAPElement message = payload.addChildElement("response");
            message.addTextNode(requestMessage);
            return soapMessage;
        } catch (SOAPException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}

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

@ -0,0 +1,59 @@
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.SOAPBody;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
@Component("wsProcessor")
public class WsProcessor implements Processor {
    public void process(final Exchange exchange) throws SOAPException {
        Object body = exchange.getIn().getBody();
        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 {
    }
}

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

@ -0,0 +1,40 @@
package camel.api7.route;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cxf.common.message.CxfConstants;
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.TestWService"
            + "&dataFormat=CXF_MESSAGE";
    // START SNIPPET: example
    public void configure() {
//        CxfComponent cxfComponent = new CxfComponent(getContext());
//        CxfEndpoint serviceEndpoint = new CxfEndpoint("http://192.168.131.101:3333/soap/ws", cxfComponent);
//        serviceEndpoint.setServiceClass(TestWService.class);
//        serviceEndpoint.setDataFormat(DataFormat.CXF_MESSAGE);
        // Here we just pass the exception back, don't need to use errorHandler
        errorHandler(noErrorHandler());
        from(SIMPLE_ENDPOINT_URI)
                .choice()
                .when(header(CxfConstants.OPERATION_NAME).isEqualTo("plus"))
                .to("bean:toWsProcessor?method=plus")
                .when(header(CxfConstants.OPERATION_NAME).isEqualTo("test"))
                .to("restlet:http://192.168.1.221:10000/api/v1.0/admin/doctors/admin/13?autoCloseStream=true")
                .to("bean:toWsProcessor?method=test")
                ;
    }
};

+ 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