Commit afca26d7 authored by Quxl's avatar Quxl

x

parent cac48379
...@@ -19,7 +19,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -19,7 +19,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import com.egolm.sso.service.XsipSdService; import com.egolm.sso.service.MaterialMasterService;
@Configuration @Configuration
public class WsConfig { public class WsConfig {
...@@ -31,13 +31,13 @@ public class WsConfig { ...@@ -31,13 +31,13 @@ public class WsConfig {
WSS4JInInterceptor authInterceptor; WSS4JInInterceptor authInterceptor;
@Autowired @Autowired
XsipSdService xsipSdService; MaterialMasterService materialMasterService;
@Bean @Bean
public Endpoint endpoint() { public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, xsipSdService); EndpointImpl endpoint = new EndpointImpl(bus, materialMasterService);
endpoint.setInInterceptors(Arrays.asList(authInterceptor)); endpoint.setInInterceptors(Arrays.asList(authInterceptor));
endpoint.publish("/xsip"); endpoint.publish("/material_master");
return endpoint; return endpoint;
} }
......
package com.egolm.sso.service;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(targetNamespace = "http://service.sso.egolm.com")
public interface MaterialMasterService {
@WebMethod
public void execute(String xml);
}
package com.egolm.sso.service;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(targetNamespace = "http://service.sso.egolm.com")
public interface XsipSdService {
/**
* 001
* @param xml
*/
@WebMethod
public void pushMaterialMaster(String xml);
/**
* 002
* @param xml
*/
@WebMethod
public void pushPriceList(String xml);
/**
* 005
* @param xml
*/
@WebMethod
public void pushProFormaInvoice(String xml);
/**
* 007
* @param xml
*/
@WebMethod
public void pushShippingNotfirmation(String xml);
/**
* 008
* @param xml
*/
@WebMethod
public void pushSoConfirmQuotation(String xml);
/**
* 009
* @param xml
*/
@WebMethod
public void pushSoDnDeletion(String xml);
}
package com.egolm.sso.service.impl;
import javax.jws.WebService;
import org.springframework.stereotype.Component;
import com.egolm.sso.service.MaterialMasterService;
@Component
@WebService(serviceName = "MaterialMasterService",
targetNamespace = "http://service.sso.egolm.com",
endpointInterface = "com.egolm.sso.service.MaterialMasterService")
public class MaterialMasterServiceImpl implements MaterialMasterService {
@Override
public void execute(String xml) {
System.out.println(xml);
}
}
package com.egolm.sso.service.impl;
import javax.jws.WebService;
import org.springframework.stereotype.Component;
import com.egolm.sso.service.XsipSdService;
@Component
@WebService(serviceName = "XsipSdService",
targetNamespace = "http://service.sso.egolm.com",
endpointInterface = "com.egolm.sso.service.XsipSdService")
public class XsipSdServiceImpl implements XsipSdService {
@Override
public void pushMaterialMaster(String xml) {
System.out.println(xml);
}
@Override
public void pushPriceList(String xml) {
System.out.println(xml);
}
@Override
public void pushProFormaInvoice(String xml) {
System.out.println(xml);
}
@Override
public void pushShippingNotfirmation(String xml) {
System.out.println(xml);
}
@Override
public void pushSoConfirmQuotation(String xml) {
System.out.println(xml);
}
@Override
public void pushSoDnDeletion(String xml) {
System.out.println(xml);
}
}
...@@ -11,29 +11,26 @@ import java.util.Map; ...@@ -11,29 +11,26 @@ import java.util.Map;
import javax.security.auth.callback.Callback; import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.CallbackHandler;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.ClientImpl; import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.WSConstants; import org.apache.ws.security.WSConstants;
import org.apache.ws.security.handler.WSHandlerConstants; import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.wss4j.common.ext.WSPasswordCallback; import org.apache.wss4j.common.ext.WSPasswordCallback;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
public class TestClient { public class TestClient001 {
private final String username = "test"; private final String username = "test";
private final String password = "78258c537d6e4d5fb210a57d05619fb6"; private final String password = "78258c537d6e4d5fb210a57d05619fb6";
private Client wsClient;
@Before @Test
public void init() { public void init() throws Exception {
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(); JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
ClientImpl client = (ClientImpl) factory.createClient("http://localhost:8080/sso/services/xsip?wsdl"); ClientImpl client = (ClientImpl) factory.createClient("http://localhost:8080/sso/services/material_master?wsdl");
Map<String, Object> properties = new HashMap<String, Object>(); Map<String, Object> properties = new HashMap<String, Object>();
properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
properties.put(WSHandlerConstants.USER, username); properties.put(WSHandlerConstants.USER, username);
...@@ -49,7 +46,8 @@ public class TestClient { ...@@ -49,7 +46,8 @@ public class TestClient {
WSS4JOutInterceptor interceptor = new WSS4JOutInterceptor(); WSS4JOutInterceptor interceptor = new WSS4JOutInterceptor();
interceptor.setProperties(properties); interceptor.setProperties(properties);
client.setOutInterceptors(Arrays.asList(interceptor)); client.setOutInterceptors(Arrays.asList(interceptor));
wsClient = client; String xml = this.readText("D:/data/sso/001.XML");
System.out.println(JSON.toJSONString(client.invoke("execute", xml)));
} }
private String readText(String path) throws IOException { private String readText(String path) throws IOException {
...@@ -67,43 +65,4 @@ public class TestClient { ...@@ -67,43 +65,4 @@ public class TestClient {
} }
} }
@Test
public void test001() throws Exception {
String xml = this.readText("D:/data/sso/001.XML");
System.out.println(JSON.toJSONString(wsClient.invoke("pushMaterialMaster", xml)));
}
@Test
public void test002() throws Exception {
String xml = this.readText("D:/data/sso/002.XML");
System.out.println(JSON.toJSONString(wsClient.invoke("pushPriceList", xml)));
}
@Test
public void test005() throws Exception {
String xml = this.readText("D:/data/sso/005.XML");
System.out.println(JSON.toJSONString(wsClient.invoke("pushProFormaInvoice", xml)));
}
@Test
public void test007() throws Exception {
String xml = this.readText("D:/data/sso/007.XML");
System.out.println(JSON.toJSONString(wsClient.invoke("pushShippingNotfirmation", xml)));
}
@Test
public void test008() throws Exception {
String xml1 = this.readText("D:/data/sso/008-1.XML");
String xml2 = this.readText("D:/data/sso/008-2.XML");
System.out.println(JSON.toJSONString(wsClient.invoke("pushSoConfirmQuotation", xml1)));
System.out.println(JSON.toJSONString(wsClient.invoke("pushSoConfirmQuotation", xml2)));
}
@Test
public void test010() throws Exception {
// String xml = this.readText("D:/data/sso/010.XML");
String xml = "文件样例暂时没有";
System.out.println(JSON.toJSONString(wsClient.invoke("pushSoDnDeletion", xml)));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment