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
d337208f
Commit
d337208f
authored
Jul 09, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
148edb3c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
ProFormaInvoiceServiceTest.java
src/test/java/test/ProFormaInvoiceServiceTest.java
+62
-0
No files found.
src/test/java/test/ProFormaInvoiceServiceTest.java
0 → 100644
View file @
d337208f
package
test
;
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
;
public
class
ProFormaInvoiceServiceTest
{
private
static
final
String
username
=
"test"
;
private
static
final
String
password
=
"78258c537d6e4d5fb210a57d05619fb6"
;
public
static
void
main
(
String
[]
args
)
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
>();
pro
.
put
(
WSHandlerConstants
.
ACTION
,
WSHandlerConstants
.
USERNAME_TOKEN
);
pro
.
put
(
WSHandlerConstants
.
USER
,
username
);
pro
.
put
(
WSHandlerConstants
.
PASSWORD_TYPE
,
WSConstants
.
PW_DIGEST
);
pro
.
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
(
pro
);
client
.
setOutInterceptors
(
Arrays
.
asList
(
interceptor
));
client
.
invoke
(
"execute"
,
readText
(
"D:/data/sso/005.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