Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sso
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
sso
Commits
35f00dac
Commit
35f00dac
authored
Jul 11, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
40f9f07a
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
141 additions
and
131 deletions
+141
-131
WsConfig.java
src/main/java/com/egolm/sso/config/WsConfig.java
+2
-2
Z_MT_SD_001_MATERIAL_MASTER.java
...services/material_master/Z_MT_SD_001_MATERIAL_MASTER.java
+2
-0
PrformaInvoiceService.java
...m/sso/services/prforma_invoice/PrformaInvoiceService.java
+12
-0
PrformaInvoiceServiceImpl.java
...o/services/prforma_invoice/PrformaInvoiceServiceImpl.java
+17
-17
Z_MT_SD_005_PERFORM_INVOICE.java
...services/prforma_invoice/Z_MT_SD_005_PERFORM_INVOICE.java
+1
-1
ServiceFactory.java
src/main/java/com/egolm/sso/util/ServiceFactory.java
+44
-0
StringUtil.java
src/main/java/com/egolm/sso/util/StringUtil.java
+18
-0
MaterialMasterServiceTest.java
src/test/java/test/MaterialMasterServiceTest.java
+13
-54
PrformaInvoiceServiceTest.java
src/test/java/test/PrformaInvoiceServiceTest.java
+20
-0
PriceListServiceTest.java
src/test/java/test/PriceListServiceTest.java
+12
-57
No files found.
src/main/java/com/egolm/sso/config/WsConfig.java
View file @
35f00dac
...
@@ -21,7 +21,7 @@ import org.springframework.context.annotation.Configuration;
...
@@ -21,7 +21,7 @@ import org.springframework.context.annotation.Configuration;
import
com.egolm.sso.services.confirm_quotation.ConfirmQuotationService
;
import
com.egolm.sso.services.confirm_quotation.ConfirmQuotationService
;
import
com.egolm.sso.services.material_master.MaterialMasterService
;
import
com.egolm.sso.services.material_master.MaterialMasterService
;
import
com.egolm.sso.services.pr
eform_invoice.Po
formaInvoiceService
;
import
com.egolm.sso.services.pr
forma_invoice.Pr
formaInvoiceService
;
import
com.egolm.sso.services.price_list.PriceListService
;
import
com.egolm.sso.services.price_list.PriceListService
;
import
com.egolm.sso.services.shipping_notfirmation.ShippingNotificationService
;
import
com.egolm.sso.services.shipping_notfirmation.ShippingNotificationService
;
...
@@ -52,7 +52,7 @@ public class WsConfig {
...
@@ -52,7 +52,7 @@ public class WsConfig {
}
}
@Bean
@Bean
public
Endpoint
getProFormaInvoicePoint
(
P
o
formaInvoiceService
priceListService
)
{
public
Endpoint
getProFormaInvoicePoint
(
P
r
formaInvoiceService
priceListService
)
{
EndpointImpl
endpoint
=
new
EndpointImpl
(
bus
,
priceListService
);
EndpointImpl
endpoint
=
new
EndpointImpl
(
bus
,
priceListService
);
endpoint
.
setInInterceptors
(
Arrays
.
asList
(
authInterceptor
));
endpoint
.
setInInterceptors
(
Arrays
.
asList
(
authInterceptor
));
endpoint
.
publish
(
"/prforma_invoice"
);
endpoint
.
publish
(
"/prforma_invoice"
);
...
...
src/main/java/com/egolm/sso/services/material_master/Z_MT_SD_001_MATERIAL_MASTER.java
View file @
35f00dac
...
@@ -4,10 +4,12 @@ import java.util.List;
...
@@ -4,10 +4,12 @@ import java.util.List;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
javax.xml.bind.annotation.XmlType
;
import
javax.xml.bind.annotation.XmlType
;
@XmlType
(
name
=
"Z_MT_SD_001_MATERIAL_MASTER"
)
@XmlType
(
name
=
"Z_MT_SD_001_MATERIAL_MASTER"
)
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
@XmlRootElement
(
name
=
"Z_MT_SD_001_MATERIAL_MASTER"
,
namespace
=
"http://schneider-distributor.com/"
)
public
class
Z_MT_SD_001_MATERIAL_MASTER
{
public
class
Z_MT_SD_001_MATERIAL_MASTER
{
RECORD
RECORD
;
RECORD
RECORD
;
...
...
src/main/java/com/egolm/sso/services/pr
eform_invoice/Po
formaInvoiceService.java
→
src/main/java/com/egolm/sso/services/pr
forma_invoice/Pr
formaInvoiceService.java
View file @
35f00dac
package
com
.
egolm
.
sso
.
services
.
pr
eform
_invoice
;
package
com
.
egolm
.
sso
.
services
.
pr
forma
_invoice
;
import
javax.jws.WebMethod
;
import
javax.jws.WebMethod
;
import
javax.jws.WebService
;
import
javax.jws.WebService
;
@WebService
(
targetNamespace
=
"http://pr
eform
_invoice.sso.egolm.com"
)
@WebService
(
targetNamespace
=
"http://pr
forma
_invoice.sso.egolm.com"
)
public
interface
P
o
formaInvoiceService
{
public
interface
P
r
formaInvoiceService
{
@WebMethod
@WebMethod
public
void
execute
(
Z_MT_SD_005_PERFORM_INVOICE
Z_MT_SD_005_PERFORM_INVOICE
);
public
void
execute
(
Z_MT_SD_005_PERFORM_INVOICE
Z_MT_SD_005_PERFORM_INVOICE
);
...
...
src/main/java/com/egolm/sso/services/pr
eform_invoice/Po
formaInvoiceServiceImpl.java
→
src/main/java/com/egolm/sso/services/pr
forma_invoice/Pr
formaInvoiceServiceImpl.java
View file @
35f00dac
package
com
.
egolm
.
sso
.
services
.
pr
eform
_invoice
;
package
com
.
egolm
.
sso
.
services
.
pr
forma
_invoice
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -13,28 +13,28 @@ import org.springframework.jdbc.core.JdbcTemplate;
...
@@ -13,28 +13,28 @@ import org.springframework.jdbc.core.JdbcTemplate;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
com.egolm.sso.services.CommonService
;
import
com.egolm.sso.services.CommonService
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_BANK_DATA
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_BANK_DATA
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_DOCU_DATE
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_DOCU_DATE
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_GENERAL_DATA
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_GENERAL_DATA
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_ORGANIZATIONAL_DATA
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_ORGANIZATIONAL_DATA
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_PARTNER_DATA
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_PARTNER_DATA
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_REFERENCE_DATA
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.HEADER_REFERENCE_DATA
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_AMOUNT_DATA
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_AMOUNT_DATA
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_DATA
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_DATA
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_MATERIAL_DATA
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_MATERIAL_DATA
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_REFERENCE_DATA
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_REFERENCE_DATA
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_REFERENCE_PO_TYPE
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_REFERENCE_PO_TYPE
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_VAT_DATA
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.ITEM_VAT_DATA
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.SUMMARY_GENERAL
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.SUMMARY_GENERAL
;
import
com.egolm.sso.services.pr
eform
_invoice.Z_MT_SD_005_PERFORM_INVOICE.Z_DT_SD_005_PERFORM_INVOICE
;
import
com.egolm.sso.services.pr
forma
_invoice.Z_MT_SD_005_PERFORM_INVOICE.Z_DT_SD_005_PERFORM_INVOICE
;
import
com.egolm.sso.util.DateUtil
;
import
com.egolm.sso.util.DateUtil
;
import
com.egolm.sso.util.SqlUtil
;
import
com.egolm.sso.util.SqlUtil
;
import
com.egolm.sso.util.SqlUtil.Sql
;
import
com.egolm.sso.util.SqlUtil.Sql
;
import
com.egolm.sso.util.StringUtil
;
import
com.egolm.sso.util.StringUtil
;
@Component
@Component
@WebService
(
serviceName
=
"P
oformaInvoiceService"
,
targetNamespace
=
"http://preform_invoice.sso.egolm.com"
,
endpointInterface
=
"com.egolm.sso.services.preform_invoice.Po
formaInvoiceService"
)
@WebService
(
serviceName
=
"P
rformaInvoiceService"
,
targetNamespace
=
"http://prforma_invoice.sso.egolm.com"
,
endpointInterface
=
"com.egolm.sso.services.prforma_invoice.Pr
formaInvoiceService"
)
public
class
P
oformaInvoiceServiceImpl
implements
Po
formaInvoiceService
{
public
class
P
rformaInvoiceServiceImpl
implements
Pr
formaInvoiceService
{
@Autowired
@Autowired
JdbcTemplate
jdbcTemplate
;
JdbcTemplate
jdbcTemplate
;
...
...
src/main/java/com/egolm/sso/services/pr
eform
_invoice/Z_MT_SD_005_PERFORM_INVOICE.java
→
src/main/java/com/egolm/sso/services/pr
forma
_invoice/Z_MT_SD_005_PERFORM_INVOICE.java
View file @
35f00dac
package
com
.
egolm
.
sso
.
services
.
pr
eform
_invoice
;
package
com
.
egolm
.
sso
.
services
.
pr
forma
_invoice
;
import
java.util.List
;
import
java.util.List
;
...
...
src/
test/java/test/ProFormaInvoiceServiceTest
.java
→
src/
main/java/com/egolm/sso/util/ServiceFactory
.java
View file @
35f00dac
package
test
;
package
com
.
egolm
.
sso
.
util
;
import
java.io.BufferedReader
;
import
java.net.URL
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
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
javax.xml.namespace.QName
;
import
javax.xml.ws.Service
;
import
org.apache.cxf.endpoint.ClientImpl
;
import
org.apache.cxf.frontend.ClientProxy
;
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
;
public
class
ProFormaInvoiceServiceTest
{
public
class
ServiceFactory
{
private
static
final
String
username
=
"test"
;
private
static
final
String
username
=
"test"
;
private
static
final
String
password
=
"78258c537d6e4d5fb210a57d05619fb6"
;
private
static
final
String
password
=
"78258c537d6e4d5fb210a57d05619fb6"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
<
T
>
T
create
(
String
wsdlLocation
,
String
namespace
,
String
serviceName
,
Class
<
T
>
requiredType
)
throws
Exception
{
JaxWsDynamicClientFactory
factory
=
JaxWsDynamicClientFactory
.
newInstance
();
ClientImpl
client
=
(
ClientImpl
)
factory
.
createClient
(
"http://localhost:8080/sso/services/pro_forma_invoice?wsdl"
);
Map
<
String
,
Object
>
pro
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
pro
=
new
HashMap
<
String
,
Object
>();
pro
.
put
(
WSHandlerConstants
.
ACTION
,
WSHandlerConstants
.
USERNAME_TOKEN
);
pro
.
put
(
WSHandlerConstants
.
ACTION
,
WSHandlerConstants
.
USERNAME_TOKEN
);
pro
.
put
(
WSHandlerConstants
.
USER
,
username
);
pro
.
put
(
WSHandlerConstants
.
USER
,
username
);
...
@@ -38,25 +33,12 @@ public class ProFormaInvoiceServiceTest {
...
@@ -38,25 +33,12 @@ public class ProFormaInvoiceServiceTest {
}
}
}
}
});
});
WSS4JOutInterceptor
interceptor
=
new
WSS4JOutInterceptor
();
URL
WSDL_URL
=
new
URL
(
wsdlLocation
);
interceptor
.
setProperties
(
pro
);
QName
qName
=
new
QName
(
namespace
,
serviceName
);
client
.
setOutInterceptors
(
Arrays
.
asList
(
interceptor
));
Service
dyService
=
Service
.
create
(
WSDL_URL
,
qName
);
client
.
invoke
(
"execute"
,
readText
(
"D:/data/sso/005.XML"
));
T
service
=
dyService
.
getPort
(
requiredType
);
ClientProxy
.
getClient
(
service
).
getOutInterceptors
().
add
(
new
WSS4JOutInterceptor
(
pro
));
return
service
;
}
}
private
static
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
();
}
}
}
}
src/main/java/com/egolm/sso/util/StringUtil.java
View file @
35f00dac
package
com
.
egolm
.
sso
.
util
;
package
com
.
egolm
.
sso
.
util
;
import
java.io.BufferedReader
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.List
;
import
java.util.List
;
import
org.dom4j.Document
;
import
org.dom4j.Document
;
...
@@ -79,4 +83,18 @@ public class StringUtil {
...
@@ -79,4 +83,18 @@ public class StringUtil {
return
format
.
substring
(
0
,
index
)
+
strno
;
return
format
.
substring
(
0
,
index
)
+
strno
;
}
}
public
static
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
();
}
}
}
}
src/test/java/test/MaterialMasterServiceTest.java
View file @
35f00dac
package
test
;
package
test
;
import
java.io.BufferedReader
;
import
com.egolm.sso.services.material_master.MaterialMasterService
;
import
java.io.FileInputStream
;
import
com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER
;
import
java.io.IOException
;
import
com.egolm.sso.util.ServiceFactory
;
import
java.io.InputStreamReader
;
import
com.egolm.sso.util.StringUtil
;
import
java.util.Arrays
;
import
com.egolm.sso.util.XMLUtil
;
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
com.alibaba.fastjson.JSON
;
public
class
MaterialMasterServiceTest
{
public
class
MaterialMasterServiceTest
{
private
static
final
String
username
=
"test"
;
private
static
final
String
password
=
"78258c537d6e4d5fb210a57d05619fb6"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
JaxWsDynamicClientFactory
factory
=
JaxWsDynamicClientFactory
.
newInstance
();
String
wsdlLocation
=
"http://localhost:8080/sso/services/material_master?wsdl"
;
ClientImpl
client
=
(
ClientImpl
)
factory
.
createClient
(
"http://localhost:8080/sso/services/material_master?wsdl"
);
String
namespace
=
"http://material_master.sso.egolm.com"
;
Map
<
String
,
Object
>
pro
=
new
HashMap
<
String
,
Object
>();
String
serviceName
=
"MaterialMasterService"
;
pro
.
put
(
WSHandlerConstants
.
ACTION
,
WSHandlerConstants
.
USERNAME_TOKEN
);
MaterialMasterService
service
=
ServiceFactory
.
create
(
wsdlLocation
,
namespace
,
serviceName
,
MaterialMasterService
.
class
);
pro
.
put
(
WSHandlerConstants
.
USER
,
username
);
String
XML
=
StringUtil
.
readText
(
"D:/data/sso/001.XML"
);
pro
.
put
(
WSHandlerConstants
.
PASSWORD_TYPE
,
WSConstants
.
PW_DIGEST
);
Z_MT_SD_001_MATERIAL_MASTER
Z_MT_SD_001_MATERIAL_MASTER
=
XMLUtil
.
toBeanByJxab
(
XML
,
Z_MT_SD_001_MATERIAL_MASTER
.
class
);
pro
.
put
(
WSHandlerConstants
.
PW_CALLBACK_REF
,
new
CallbackHandler
()
{
service
.
execute
(
Z_MT_SD_001_MATERIAL_MASTER
);
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
(
pro
);
client
.
setOutInterceptors
(
Arrays
.
asList
(
interceptor
));
client
.
invoke
(
"execute"
,
readText
(
"D:/data/sso/001.XML"
));
}
}
private
static
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
();
}
}
}
}
src/test/java/test/PrformaInvoiceServiceTest.java
0 → 100644
View file @
35f00dac
package
test
;
import
com.egolm.sso.services.prforma_invoice.PrformaInvoiceService
;
import
com.egolm.sso.services.prforma_invoice.Z_MT_SD_005_PERFORM_INVOICE
;
import
com.egolm.sso.util.ServiceFactory
;
import
com.egolm.sso.util.StringUtil
;
import
com.egolm.sso.util.XMLUtil
;
public
class
PrformaInvoiceServiceTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
wsdlLocation
=
"http://localhost:8080/sso/services/prforma_invoice?wsdl"
;
String
namespace
=
"http://prforma_invoice.sso.egolm.com"
;
String
serviceName
=
"PrformaInvoiceService"
;
PrformaInvoiceService
service
=
ServiceFactory
.
create
(
wsdlLocation
,
namespace
,
serviceName
,
PrformaInvoiceService
.
class
);
String
XML
=
StringUtil
.
readText
(
"D:/data/sso/005.XML"
);
Z_MT_SD_005_PERFORM_INVOICE
Z_MT_SD_005_PERFORM_INVOICE
=
XMLUtil
.
toBeanByJxab
(
XML
,
Z_MT_SD_005_PERFORM_INVOICE
.
class
);
service
.
execute
(
Z_MT_SD_005_PERFORM_INVOICE
);
}
}
src/test/java/test/PriceListServiceTest.java
View file @
35f00dac
package
test
;
package
test
;
import
java.io.BufferedReader
;
import
com.egolm.sso.services.material_master.MaterialMasterService
;
import
java.io.FileInputStream
;
import
com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER
;
import
java.io.IOException
;
import
com.egolm.sso.util.ServiceFactory
;
import
java.io.InputStreamReader
;
import
com.egolm.sso.util.StringUtil
;
import
java.util.Arrays
;
import
com.egolm.sso.util.XMLUtil
;
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
com.alibaba.fastjson.JSON
;
public
class
PriceListServiceTest
{
public
class
PriceListServiceTest
{
private
static
final
String
username
=
"test"
;
private
static
final
String
password
=
"78258c537d6e4d5fb210a57d05619fb6"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
JaxWsDynamicClientFactory
factory
=
JaxWsDynamicClientFactory
.
newInstance
();
String
wsdlLocation
=
"http://localhost:8080/sso/services/price_list?wsdl"
;
ClientImpl
client
=
(
ClientImpl
)
factory
.
createClient
(
"http://localhost:8080/sso/services/price_list?wsdl"
);
String
namespace
=
"http://price_list.sso.egolm.com"
;
Map
<
String
,
Object
>
properties
=
new
HashMap
<
String
,
Object
>();
String
serviceName
=
"PriceListService"
;
properties
.
put
(
WSHandlerConstants
.
ACTION
,
WSHandlerConstants
.
USERNAME_TOKEN
);
MaterialMasterService
service
=
ServiceFactory
.
create
(
wsdlLocation
,
namespace
,
serviceName
,
MaterialMasterService
.
class
);
properties
.
put
(
WSHandlerConstants
.
USER
,
username
);
String
XML
=
StringUtil
.
readText
(
"D:/data/sso/001.XML"
);
properties
.
put
(
WSHandlerConstants
.
PASSWORD_TYPE
,
WSConstants
.
PW_DIGEST
);
Z_MT_SD_001_MATERIAL_MASTER
Z_MT_SD_001_MATERIAL_MASTER
=
XMLUtil
.
toBeanByJxab
(
XML
,
Z_MT_SD_001_MATERIAL_MASTER
.
class
);
properties
.
put
(
WSHandlerConstants
.
PW_CALLBACK_REF
,
new
CallbackHandler
()
{
service
.
execute
(
Z_MT_SD_001_MATERIAL_MASTER
);
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
=
readText
(
"D:/data/sso/002.XML"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
client
.
invoke
(
"execute"
,
xml
)));
}
private
static
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
();
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment