Commit 357edd91 authored by Quxl's avatar Quxl

x

parent 820edb78
package com.egolm.sso.config; package com.egolm.sso.config;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -19,7 +18,8 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -19,7 +18,8 @@ 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.MaterialMasterService; import com.egolm.sso.material_master.TestMaterialMaster;
@Configuration @Configuration
public class WsConfig { public class WsConfig {
...@@ -31,12 +31,12 @@ public class WsConfig { ...@@ -31,12 +31,12 @@ public class WsConfig {
WSS4JInInterceptor authInterceptor; WSS4JInInterceptor authInterceptor;
@Autowired @Autowired
MaterialMasterService materialMasterService; TestMaterialMaster materialMasterService;
@Bean @Bean
public Endpoint endpoint() { public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(bus, materialMasterService); EndpointImpl endpoint = new EndpointImpl(bus, materialMasterService);
endpoint.setInInterceptors(Arrays.asList(authInterceptor)); //endpoint.setInInterceptors(Arrays.asList(authInterceptor));
endpoint.publish("/material_master"); endpoint.publish("/material_master");
return endpoint; return endpoint;
} }
......
package com.egolm.sso.material_master;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(targetNamespace = "http://material_master.sso.egolm.com")
public interface TestMaterialMaster {
@WebMethod
public void execute(Z_MI_SD_001_MATERIAL_MASTER Z_MI_SD_001_MATERIAL_MASTER);
}
package com.egolm.sso.material_master;
import javax.jws.WebService;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
@Component
@WebService(serviceName = "TestMaterialMaster", targetNamespace = "http://material_master.sso.egolm.com", endpointInterface = "com.egolm.sso.material_master.TestMaterialMaster")
public class TestMaterialMasterImpl implements TestMaterialMaster {
@Override
public void execute(Z_MI_SD_001_MATERIAL_MASTER Z_MI_SD_001_MATERIAL_MASTER) {
System.out.println(JSON.toJSON(Z_MI_SD_001_MATERIAL_MASTER));
}
}
package com.egolm.sso.material_master;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Z_MI_SD_001_MATERIAL_MASTER", propOrder = { "RECORD" })
public class Z_MI_SD_001_MATERIAL_MASTER {
@XmlElement(name = "RECORD", required = true)
protected Z_MI_SD_001_MATERIAL_MASTER.RECORD RECORD;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "HEADER_SENDING", "ITEM" })
public static class RECORD {
@XmlElement(name = "HEADER_SENDING", required = true)
protected Z_MI_SD_001_MATERIAL_MASTER.RECORD.HEADER_SENDING HEADER_SENDING;
@XmlElement(name = "ITEM", required = true)
protected List<Z_MI_SD_001_MATERIAL_MASTER.RECORD.ITEM> ITEM;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "KUNNR", "DATUM", "UZEIT" })
public static class HEADER_SENDING {
@XmlElement(name = "KUNNR")
protected String KUNNR;
@XmlElement(name = "DATUM")
protected String DATUM;
@XmlElement(name = "UZEIT")
protected String UZEIT;
public String getKUNNR() {
return KUNNR;
}
public void setKUNNR(String kUNNR) {
KUNNR = kUNNR;
}
public String getDATUM() {
return DATUM;
}
public void setDATUM(String dATUM) {
DATUM = dATUM;
}
public String getUZEIT() {
return UZEIT;
}
public void setUZEIT(String uZEIT) {
UZEIT = uZEIT;
}
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "MATNR", "BRGEW", "NTGEW", "GEWEI", "PLINE", "ERSDA", "LAEDA", "NORMT", "LIFNR", "VMSTA", "MSTAV", "STKTYP", "UMREZ" })
public static class ITEM {
@XmlElement(name = "MATNR")
protected String MATNR;
@XmlElement(name = "BRGEW")
protected String BRGEW;
@XmlElement(name = "NTGEW")
protected String NTGEW;
@XmlElement(name = "GEWEI")
protected String GEWEI;
@XmlElement(name = "PLINE")
protected String PLINE;
@XmlElement(name = "ERSDA")
protected String ERSDA;
@XmlElement(name = "LAEDA")
protected String LAEDA;
@XmlElement(name = "NORMT")
protected String NORMT;
@XmlElement(name = "LIFNR")
protected String LIFNR;
@XmlElement(name = "VMSTA")
protected String VMSTA;
@XmlElement(name = "MSTAV")
protected String MSTAV;
@XmlElement(name = "STKTYP")
protected String STKTYP;
@XmlElement(name = "UMREZ")
protected String UMREZ;
public String getMATNR() {
return MATNR;
}
public void setMATNR(String mATNR) {
MATNR = mATNR;
}
public String getBRGEW() {
return BRGEW;
}
public void setBRGEW(String bRGEW) {
BRGEW = bRGEW;
}
public String getNTGEW() {
return NTGEW;
}
public void setNTGEW(String nTGEW) {
NTGEW = nTGEW;
}
public String getGEWEI() {
return GEWEI;
}
public void setGEWEI(String gEWEI) {
GEWEI = gEWEI;
}
public String getPLINE() {
return PLINE;
}
public void setPLINE(String pLINE) {
PLINE = pLINE;
}
public String getERSDA() {
return ERSDA;
}
public void setERSDA(String eRSDA) {
ERSDA = eRSDA;
}
public String getLAEDA() {
return LAEDA;
}
public void setLAEDA(String lAEDA) {
LAEDA = lAEDA;
}
public String getNORMT() {
return NORMT;
}
public void setNORMT(String nORMT) {
NORMT = nORMT;
}
public String getLIFNR() {
return LIFNR;
}
public void setLIFNR(String lIFNR) {
LIFNR = lIFNR;
}
public String getVMSTA() {
return VMSTA;
}
public void setVMSTA(String vMSTA) {
VMSTA = vMSTA;
}
public String getMSTAV() {
return MSTAV;
}
public void setMSTAV(String mSTAV) {
MSTAV = mSTAV;
}
public String getSTKTYP() {
return STKTYP;
}
public void setSTKTYP(String sTKTYP) {
STKTYP = sTKTYP;
}
public String getUMREZ() {
return UMREZ;
}
public void setUMREZ(String uMREZ) {
UMREZ = uMREZ;
}
}
public Z_MI_SD_001_MATERIAL_MASTER.RECORD.HEADER_SENDING getHEADER_SENDING() {
return HEADER_SENDING;
}
public void setHEADER_SENDING(Z_MI_SD_001_MATERIAL_MASTER.RECORD.HEADER_SENDING hEADER_SENDING) {
HEADER_SENDING = hEADER_SENDING;
}
public List<Z_MI_SD_001_MATERIAL_MASTER.RECORD.ITEM> getITEM() {
return ITEM;
}
public void setITEM(List<Z_MI_SD_001_MATERIAL_MASTER.RECORD.ITEM> iTEM) {
ITEM = iTEM;
}
}
public Z_MI_SD_001_MATERIAL_MASTER.RECORD getRECORD() {
return RECORD;
}
public void setRECORD(Z_MI_SD_001_MATERIAL_MASTER.RECORD rECORD) {
RECORD = rECORD;
}
}
package com.schneider_distributor;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.schneider_distributor package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _ZMTSD009SOCREATION_QNAME = new QName("http://schneider-distributor.com/", "Z_MT_SD_009_SO_CREATION");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.schneider_distributor
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link ZDTSD009SOCREATION }
*
*/
public ZDTSD009SOCREATION createZDTSD009SOCREATION() {
return new ZDTSD009SOCREATION();
}
/**
* Create an instance of {@link ZDTSD009SOCREATION.Header }
*
*/
public ZDTSD009SOCREATION.Header createZDTSD009SOCREATIONHeader() {
return new ZDTSD009SOCREATION.Header();
}
/**
* Create an instance of {@link ZDTSD009SOCREATION.ITEM }
*
*/
public ZDTSD009SOCREATION.ITEM createZDTSD009SOCREATIONITEM() {
return new ZDTSD009SOCREATION.ITEM();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link ZDTSD009SOCREATION }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://schneider-distributor.com/", name = "Z_MT_SD_009_SO_CREATION")
public JAXBElement<ZDTSD009SOCREATION> createZMTSD009SOCREATION(ZDTSD009SOCREATION value) {
return new JAXBElement<ZDTSD009SOCREATION>(_ZMTSD009SOCREATION_QNAME, ZDTSD009SOCREATION.class, null, value);
}
}
package com.schneider_distributor;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;
/**
* This class was generated by Apache CXF 3.2.9
* 2019-07-05T14:08:11.116+08:00
* Generated source version: 3.2.9
*
*/
@WebService(targetNamespace = "http://schneider-distributor.com/", name = "Z_MI_SD_009_SO_CREATION")
@XmlSeeAlso({ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface ZMISD009SOCREATION {
@WebMethod(operationName = "Z_MI_SD_009_SO_CREATION", action = "http://sap.com/xi/WebService/soap1.1")
@Oneway
public void zMISD009SOCREATION(
@WebParam(partName = "Z_MT_SD_009_SO_CREATION", name = "Z_MT_SD_009_SO_CREATION", targetNamespace = "http://schneider-distributor.com/")
ZDTSD009SOCREATION zMTSD009SOCREATION
);
}
package com.schneider_distributor;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;
/**
* This class was generated by Apache CXF 3.2.9
* 2019-07-05T14:08:11.147+08:00
* Generated source version: 3.2.9
*
*/
@WebServiceClient(name = "Z_MI_SD_009_SO_CREATIONService",
wsdlLocation = "file:/C:/Users/Quxl/Desktop/Z_MI_SD_009_SO_CREATION.wsdl",
targetNamespace = "http://schneider-distributor.com/")
public class ZMISD009SOCREATIONService extends Service {
public final static URL WSDL_LOCATION;
public final static QName SERVICE = new QName("http://schneider-distributor.com/", "Z_MI_SD_009_SO_CREATIONService");
public final static QName ZMISD009SOCREATIONPort = new QName("http://schneider-distributor.com/", "Z_MI_SD_009_SO_CREATIONPort");
static {
URL url = null;
try {
url = new URL("file:/C:/Users/Quxl/Desktop/Z_MI_SD_009_SO_CREATION.wsdl");
} catch (MalformedURLException e) {
java.util.logging.Logger.getLogger(ZMISD009SOCREATIONService.class.getName())
.log(java.util.logging.Level.INFO,
"Can not initialize the default wsdl from {0}", "file:/C:/Users/Quxl/Desktop/Z_MI_SD_009_SO_CREATION.wsdl");
}
WSDL_LOCATION = url;
}
public ZMISD009SOCREATIONService(URL wsdlLocation) {
super(wsdlLocation, SERVICE);
}
public ZMISD009SOCREATIONService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public ZMISD009SOCREATIONService() {
super(WSDL_LOCATION, SERVICE);
}
public ZMISD009SOCREATIONService(WebServiceFeature ... features) {
super(WSDL_LOCATION, SERVICE, features);
}
public ZMISD009SOCREATIONService(URL wsdlLocation, WebServiceFeature ... features) {
super(wsdlLocation, SERVICE, features);
}
public ZMISD009SOCREATIONService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns ZMISD009SOCREATION
*/
@WebEndpoint(name = "Z_MI_SD_009_SO_CREATIONPort")
public ZMISD009SOCREATION getZMISD009SOCREATIONPort() {
return super.getPort(ZMISD009SOCREATIONPort, ZMISD009SOCREATION.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns ZMISD009SOCREATION
*/
@WebEndpoint(name = "Z_MI_SD_009_SO_CREATIONPort")
public ZMISD009SOCREATION getZMISD009SOCREATIONPort(WebServiceFeature... features) {
return super.getPort(ZMISD009SOCREATIONPort, ZMISD009SOCREATION.class, features);
}
}
@javax.xml.bind.annotation.XmlSchema(namespace = "http://schneider-distributor.com/")
package com.schneider_distributor;
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="Z_MI_SD_009_SO_CREATION" targetNamespace="http://schneider-distributor.com/" xmlns:p1="http://schneider-distributor.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="http://schneider-distributor.com/" xmlns="http://schneider-distributor.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Z_MT_SD_009_SO_CREATION" type="Z_DT_SD_009_SO_CREATION" />
<xsd:complexType name="Z_DT_SD_009_SO_CREATION">
<xsd:sequence>
<xsd:element name="Header">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">a3b37530b5ca11dbadee001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Header Line</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="BSTKD_E" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">a3b37531b5ca11dbafa9001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Customer purchase order number</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="36" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="VBELN" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">d7dd56f0b5ca11db8a66001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Quotation Number</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="BSTDK" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">d7dd56f1b5ca11dbad16001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">PO Date</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="8" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="KUNNR" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">d7dd56f2b5ca11db954a001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Sold-to party</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="KGNNR" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">d7dd56f3b5ca11dbc0dc001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Ship-to party</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="QTFLAG" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">ebf40260b5ca11dbc7e0001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Quotation Flag</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="1" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ITEM" minOccurs="0" maxOccurs="unbounded" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">f60110b0b67711db827c001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">ITEM DATA</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="POSNR" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">f60110b1b67711dba026001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Item number</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="6" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="VTEXT" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">f60110b2b67711dbc938001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Item number of the underlying customer purchase order</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="40" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="MATNR" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">f60110b3b67711dbc52c001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Material Number</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="18" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="KWMENG" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">f60110b4b67711db9a2b001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Quantity Quantity</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="15" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="EDATU" minOccurs="0">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">f60110b5b67711db9b3f001641a70fb2</xsd:appinfo>
<xsd:documentation xml:lang="ZH">Customer request delivery date</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="8" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="Z_MT_SD_009_SO_CREATION">
<wsdl:part name="Z_MT_SD_009_SO_CREATION" element="p1:Z_MT_SD_009_SO_CREATION" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
</wsdl:message>
<wsdl:portType name="Z_MI_SD_009_SO_CREATION">
<wsdl:operation name="Z_MI_SD_009_SO_CREATION">
<wsdl:input message="p1:Z_MT_SD_009_SO_CREATION" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Z_MI_SD_009_SO_CREATIONBinding" type="p1:Z_MI_SD_009_SO_CREATION" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" />
<wsdl:operation name="Z_MI_SD_009_SO_CREATION">
<soap:operation soapAction="http://sap.com/xi/WebService/soap1.1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" />
<wsdl:input>
<soap:body use="literal" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" />
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Z_MI_SD_009_SO_CREATIONService">
<wsdl:port name="Z_MI_SD_009_SO_CREATIONPort" binding="p1:Z_MI_SD_009_SO_CREATIONBinding" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<soap:address location="http://xiprd:8000/sap/xi/engine?type=entry&amp;version=3.0&amp;Sender.Service=S000000002&amp;Interface=http%3A%2F%2Fschneider-distributor.com%2F%5EZ_MI_SD_009_SO_CREATION" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
\ No newline at end of file
package sso;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import org.apache.cxf.endpoint.ClientImpl;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.wss4j.common.ext.WSPasswordCallback;
import org.junit.Test;
import com.alibaba.fastjson.JSON;
public class MaterialMasterServiceTest {
private final String username = "test";
private final String password = "78258c537d6e4d5fb210a57d05619fb6";
@Test
public void init() throws Exception {
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
ClientImpl client = (ClientImpl) factory.createClient("http://localhost:8080/sso/services/material_master?wsdl");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
properties.put(WSHandlerConstants.USER, username);
properties.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
public void handle(Callback[] callbacks) {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
pc.setPassword(password);
}
}
});
WSS4JOutInterceptor interceptor = new WSS4JOutInterceptor();
interceptor.setProperties(properties);
client.setOutInterceptors(Arrays.asList(interceptor));
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 {
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(path)));
String line = null;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line);
}
return sb.toString();
} finally {
br.close();
}
}
}
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