1
我試着用JAXB和SpringWS開發Web服務。 但我有一個問題。 我把我的wss安全和我如何創建標題?JAXB Header security with Spring-WS
這是我的實際代碼:
背景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;
}
}
這是客戶端
public class MonsterWSClient extends WebServiceGatewaySupport {
public JobsResponse updateJob(Job request) {
return (JobsResponse) getWebServiceTemplate().marshalSendAndReceive(request,
new SoapActionCallback(getDefaultUri() + "/createOffer"));
}
}
,這是主要的:
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));
}
}
- 我已經創建了Job對象。
- 但我不明白我在哪裏把我的憑據頭。
謝謝。
喜,但現在我還有一個問題,當我啓動這個程序,錯誤創建與home.LaunchCall定義名稱「查找」豆:不滿意的依賴,通過構造函數的參數表示索引爲0類型爲[MonsterWSClient]:未找到符合條件的[com.proximainformatica.client.MonsterWSClient]類型的合格bean:期望至少1個符合此依賴關係自動裝配候選資格的bean。依賴註釋:{};嵌套異常是org.springframework.beans.factory.NoSuchBeanDefinitionException:找不到符合條件的[MonsterWSClient]類型的合格bean:expected .. – reve