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

Control headers from SSI-included JSP
opening a shared local folder(C drive or D Drive etc..) from a JSP deployed in a tomcat server
request.getParameter(“f”) evaluates to null
Return an element of a for-loop outside the for-loop
Is it good to have enum implementation with processing logic?
Null Pointer Exception without package name Or class Name
Configuring SPRING Data JPA for same database on 2 different servers using Spring annotations
Kotlin. How to check if the field is nullable via reflection?
InterruptedException during put operation SSM Xmemcached
Could Java EE Batch Job wait event?
Maven: Error upon compiling
Tomcat 9.0 server can't start
Tomcat thread suspend 15m26s
How to create pojo class using json data/json response in java?
Android Editable is abstract; cannot be instantiated [duplicate]
forward requests of unresolved request mapping by changing the context root (spring-rest)

Categories

HOME
log4j
push-notification
hp-exstream
vmware
relay
pheatmap
synchronization
google-translate
tomcat6
reveal.js
correlation
percona
jsprit
clojurescript
pc
apache-metamodel
connection-string
scriptcs
language-agnostic
blazemeter
rundeck
h2db
url-scheme
wpfdatagrid
social-media
typo3-6.2.x
neo4j-spatial
instant-messaging
media-queries
frame
directx-10
oracle-fusion-middleware
azure-sql-database
atl
y86
serve
qwerty
webdriver-manager
trim
sas-visual-analytics
optix
android-mediaprojection
import-from-excel
long-polling
outlook-2013
termination
promela
aurelia-validation
drupal-6
sonarlint-vs
chord-diagram
mediaelement
rhino-servicebus
ios8-today-widget
maven-tomcat-plugin
reactive-banana
feedback
quicklisp
system32
kineticjs
oxwall
jscript.net
qcodo
braille
mcts
uv-mapping
gridfs
inbox
apc
mylyn
xamlparseexception
typoscript2
chuck
manchester-syntax
online-compilation
osql
bigcouch
deobfuscation
horizontal-accordion
jmock
remember-me
site.master
gamequery
brewmp
anti-piracy
sector
data-acquisition
rtml
misv





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