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 do I annotate a JAXB property to use xsd:time rather than xsd:datetime?
java and memory layout
Is there any library to deserialize with python which is serialized with java
Converting a WSDL file into XSD file in java
Check and insert alt attribute for images which miss it
Java - Store GMT time
Writing functional programs in non-functional languages
Java EE and application servers - What can i do?
What are Java's native ways of communicating with devices directly?
when we use Semaphore in consumer and producer buffer
How can I disable all images for an JFace menu but leave them enabled in the toolbar
Simple exception handling in Java
com.liferay.util.PwdGenerator
read file in classpath
Give an Executable Jar a Custom Image
How is the java memory pool divided?

Categories

HOME
isabelle
view
office365api
relayjs
octobercms
xmpp
framework7
bookshelf.js
adb
programming-languages
bs4
tomcat6
flask-wtforms
zebra-printers
carthage
jsprit
facebook-page
normalizr
firefox-webextensions
paging
graphicsmagick
mustache.php
cultureinfo
opennlp
facet
fgetcsv
buck
jaxb2
socialengine
media-queries
calibre
phpfreechat
catalog
reportbuilder
ansible-playbook
awt
thin
wptoolkit
auto-update
fault
ionicons
fancybox-2
elgg
typed-lambda-calculus
orthogonal
specrun
grails-tomcat-plugin
asp.net-4.5
qpid
captivenetwork
browser-link
iad
jms2
lib.web.mvc
pundit
responsive-images
method-parameters
processmodel
sonarqube5.1.2
truevault
c++03
csquery
nsmutabledictionary
typekit
camanjs
tt-news
angularjs-ng-click
flask-cors
xojo
article
contenttype
elliptic-curve
jquery-layout
kgdb
bundles
jboss-weld
hyprlinkr
balanced-payments
message-driven-bean
monomac
imdbpy
mysqltuner
access-rights
cdc
android-screen-support
html-editor
delphi-6
runas
onsubmit
regsvr32
semantic-diff
boost-filesystem
stage
zpt
heartbeat
netbeans-7.1
datareader
sortable-tables
preference
mirah
zend-tool
swing-app-framework
text-coloring

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