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 send a separate default text every time text is sent via SMS service from android app?
How to run powershell script from remote machine with Java?
ComboBoxViewerCellEditor and AutoCompleteField doesn't work
Add icon to a (link) element / element in element
Suppress Keyword Expansion in Shell Script
Mongo match in aggregate not working for date using java
Java method arguments of two types
Neo4j queries slows down but after restart are fast again
Execute linux command in java and display output to html table
Java Annotations javaArgs and LiteralArguments are deprecated
NoSuchMethodError while parsing xsd to generate classes using JAXB
Hibernate using sql call for each row to fetch relationship - instead of aggregating to one IN clause
How do I make a local variable increase consistently in a recursive function having more than one calls?
Intellij IDEA : Spark code running results in java.lang.VerifyError
JavaParser comparison
How To use setOnItemClickListner multiple times in a ListView?

Categories

HOME
vbscript
pycharm
rsyslog
dxl
angular-ui-bootstrap
alpha
networkx
bs4
amazon-cloudformation
primary-key
izpack
quicklook
static-libraries
fallback
hapi
clojurescript
contextmenu
crystal-reports-2008
amazonsellercentral
zapier
orleans
core-text
hammerspoon
crosstab
p-value
fish
linkerd
saas
calibre
catch-all
framemaker
vsts-build-task
repo
atl
ios5
dosbox
xcode-extension
lto
sqlite2
graphenedb
g-code
texmaker
midl
eclipse-gef
wptoolkit
angular-resource
zip4j
dotnetzip
powercli
aurelia-validation
font-size
android-cursor
django-scheduler
blacklist
angular-strap
setuptools
infix-notation
probability-density
bstr
packagist
pyke
historian
qtableview
lib.web.mvc
device-manager
onactivityresult
expected-exception
braille
transcoding
meteor-velocity
typo3-neos
sitemesh
web2py-modules
shellexecute
isnullorempty
runas
viewswitcher
data-loss
f#-powerpack
locationlistener
ecl
locate
html-input
zend-translate
coda-slider
filtered-index
vc90
fixed-width
memory-size
noscript
ubuntu-9.04

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