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

How to retrieve only the PKs of a table
File host for android App
Soap webservice: alert posting Mantas error
adf refresh mysql auto_increment “ID” not shown until query is re-executed
Dealing with different String date formats
Associations and hashmaps in java
Google Maps Geolocation API only ever returning location of 1st tower in my array
Avoid auto-scroll to bottom after calling setViewportView in a JScrollPane
Add js file with parametar in Tapestry
How to set the error correction level of a QRC using QRGen?
Pass zero-sized array, save allocation?
Is it possible to view the Object Graph JAXB analyzes?
Android bluetooth connection doesn't close after application crash
How to set up Java VM to use the root certificates (truststore) handled by Mac OS X
What should I consider while creating virtual dealer in my blackjack game?
File contents are wiped when trying to read from Scanner

Categories

HOME
openlayers
asp.net-core
openmp
ngrx
angular-material
layout
fft
iot
sd-card
cvs
leon
pivotal-cloud-foundry
echarts
indesign
autotools
applepay
elasticsearch-hadoop
session-variables
google-translate
gnupg
vifm
nstableview
usergrid
leiningen
visual-studio-2005
normalizr
django-cms
firefox-webextensions
custom-wordpress-pages
java-3d
cloudhub
arabic
sox
kvc
bootstrap-tour
tibco-mdm
qhull
user-interaction
atlassian-crucible
galsim
google-cloud-endpoints-v2
phpfreechat
normal-distribution
nssegmentedcontrol
fusionpbx
io-redirection
suricata
file-format
temporary-files
galen
google-closure
http-live-streaming
estimote
scorm
osx-mavericks
filepicker
celery-task
carrot
parallel-data-warehouse
jquery-filter
static-ip-address
heidisql
database-optimization
transmitfile
hill-climbing
essence
apachebench
photobucket
hsv
pervasive-sql
wso2cloud
google-places
tarjans-algorithm
emailrelay
unity3d-gui
tablelayout
android-imagebutton
onactivityresult
sgen
dotnetnuke-5
buster.js
gwt-rpc
mqx
dice
transactionscope
spyware
coredump
coercion
psi
xtype
remember-me
forums
ti-dsp

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