java


JAXB Header security with Spring-WS


im try to develop a webservices with JAXB and SpringWS.
but i have a question.
Where i put my wss Security and how i create a Header?
this is my actual code:
CONTEXT SPRING CLIENT
#Configuration
public class MonsterWSClientContext {
private static final String URL = "AAA";
private static final String TEST_URL = "TEST";
private static final String WS_URL = TEST_URL + "/soap/WSOfferService";
#Bean
#Autowired
public MonsterWSClient monsterClient(Jaxb2Marshaller marshaller) {
MonsterWSClient client = new MonsterWSClient();
client.setDefaultUri(WS_URL);
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
return client;
}
#Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
jaxb2Marshaller.setPackagesToScan(com.monster.schemas.monster.ObjectFactory.class.getPackage().getName(),
com.monster.schemas.monsterheader.ObjectFactory.class.getPackage().getName(),
com.monster.schemas.ObjectFactory.class.getPackage().getName(),
com.monster.webservices.monsterportal.ObjectFactory.class.getPackage().getName());
return jaxb2Marshaller;
}
}
this is the client
public class MonsterWSClient extends WebServiceGatewaySupport {
public JobsResponse updateJob(Job request) {
return (JobsResponse) getWebServiceTemplate().marshalSendAndReceive(request,
new SoapActionCallback(getDefaultUri() + "/createOffer"));
}
}
and this is the main:
public class Test {
public JobsResponse callMonster(String jobRefCode, String userName,
InformazioniAnnuncio datiAnnuncio)
{
MonsterWSClient client = new MonsterWSClient();
JobsResponse response = new JobsResponse();
return response = client.updateJob(createJob(jobRefCode, userName, datiAnnuncio));
}
}
i have create the Job object.
but i dont understand where i put the header with my credential.
Thanks.
You'll have to use spring-ws-security. Use this link spring ws security .This page has all the security related settings and you'll need to set up Wss4jSecurityInterceptor with your username and password.
Something like this
#Bean
public Wss4jSecurityInterceptor securityInterceptor() {
Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
securityInterceptor.setSecurementActions("UsernameToken");
securityInterceptor.setSecurementUsername({username});
securityInterceptor.setSecurementPassword({password});
securityInterceptor.setSecurementPasswordType("PasswordText");
securityInterceptor.setSecurementUsernameTokenElements("Created");
return securityInterceptor;

Related Links

Detecting late responses
Splitting this string (var1=val1&&var2=val2) using regular expressions in java
Why is Eclipse not showing values of all objects in the Debug perspective?
Passing info message to a Wicket page while using PageParameters
How to add result to resultset of a MySQL stored procedure in java
upgrade project to grails 2.0.1
Both #Component and #Named for the same bean class
Java phonetics or language pronounciation
exec-maven-plugin exec:java failing: Cannot assign configuration values to array of type java.lang.String
Weird points and lines appearing in custom JPanel when another component updates
How can I create a decimal-only BasicEditField in BlackBerry?
Sax parser issues in android
Implement a workchain with templatemethod pattern?
trying to create a phantom in MySQL under the REPEATABLE-READ isolation level
JTree and TreeModel with hierarchy of varying class?
Java Panel Won't Paint

Categories

HOME
hive
coq
openmp
amazon-ec2
reflection
office365api
relayjs
gps
ravendb
medical
awesome-wm
cloudkit
tomcat6
dax
resize
moonmail
gz
try-catch
dosgi
jsdoc
textfield
jprofiler
zapier
visjs
one-hot-encoding
jasonette
mustache.php
core-text
cultureinfo
pepper
selectedindexchanged
url-scheme
windows-error-reporting
large-file-upload
flink-streaming
react-chartjs
pdb
pim
asset-pipeline
stacked
devextreme
dartium
libvpx
service-discovery
webix-treetable
reportingservices-2005
s
sencha-touch-2.3
websphere-mq-fte
angular2-meteor
galleria
scorm
upstart
paxos
pnotify
yii2-extension
slickedit
nsarray
nbconvert
titanium-android
blacklist
or-tools
yt-project
ableton-live
simplewebrtc
lua-5.1
dataview
msys
iiviewdeckcontroller
truevault
offloading
relocation
markers
flask-cors
ceil
concurrent-collections
meteor-velocity
mcts
floating-point-precision
commoncrypto
lcs
ocunit
kyotocabinet
jquery-knob
google-email-migration
runas
venn-diagram
bubble-chart
removeclass
coredump
hamachi
yetanotherforum
file-comparison
calling-convention
sproutcore-2
sef
temporal-database
sector
genealogy
msdev
windows-live-messenger

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App