Eway Payment Gateway: Add Headers using SOAP Service in Recuring payment Using Java

匿名 (未验证) 提交于 2019-12-03 01:40:02

问题:

I am trying to use eway payment gateway. In this i am using Recurring payment. For recurring they provide WSDL file, by using Maven Generator, i was creating java classes from WSDL file. When i was trying to call services, it generate an error, because the service need authentication information in SOAP header. From this Link i found the Solution to add header in SOAP request using Jaxb Object. After that, when i call the SOAP services it generates different error, which confused me. following is my code for handle eway recurring services: 1. SOAP Handler

public class EwaySOAPHandler implements SOAPHandler<SOAPMessageContext>{ private JAXBElement<EWAYHeader> jaxbElement = null;  public EwaySOAPHandler(JAXBElement<EWAYHeader> jaxbElement) {     this.jaxbElement = jaxbElement; }  public boolean handleMessage(SOAPMessageContext context) {     Boolean outBoundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);     try{         if(outBoundProperty != null && outBoundProperty.booleanValue()){             Marshaller marshaller = JAXBContext.newInstance(EWAYHeader.class).createMarshaller();             SOAPHeader header = context.getMessage().getSOAPPart().getEnvelope().addHeader();             marshaller.marshal(jaxbElement, header);         }         return false;     }catch(Exception ex){         System.out.println("Problem In Handel Message");         ex.printStackTrace();     }     return true; }  public boolean handleFault(SOAPMessageContext context) {     throw new UnsupportedOperationException("Not Supported Yet"); }  public void close(MessageContext context) {  }  public Set<QName> getHeaders() {     return new TreeSet<QName>(); } }

2. SOAP Client

public class SOAPClient { @Test public void test() {     ManageRebill manageRebill = new ManageRebill();     ManageRebillSoap manageRebillSoap = manageRebill.getManageRebillSoap();     Binding binding = ((BindingProvider) manageRebillSoap).getBinding();     List<Handler> handlersList = new ArrayList<Handler>();      EWAYHeader header = new EWAYHeader();     header.setEWAYCustomerID("87654321");     header.setPassword("test");     header.setUsername("test@eway.com.au");      ObjectFactory factory = new ObjectFactory();     JAXBElement<EWAYHeader> jaxbElement = factory.createEWAYHeader(header);     EwaySOAPHandler ewaySOAPHandler = new EwaySOAPHandler(jaxbElement);      handlersList.add(ewaySOAPHandler);     binding.setHandlerChain(handlersList);      manageRebillSoap.createRebillCustomer("Mr", "Pritpal", "Singh",             "Mohali", "CHD", "Punjab", "netsol", "1610032", "india",             "abc@abc.com", "123456789", "123456789", "987654321", "Ref123",             "JavaEE Developer", "comments", "http://google.com"); }}

Following error is generate when i try to run SOAPClient test case: com.sun.xml.internal.ws.streaming.XMLStreamReaderException: unexpected XML tag. expected: {http://www.eway.com.au/gateway/rebill/manageRebill}CreateRebillCustomerResponse but found: {http://www.eway.com.au/gateway/rebill/manageRebill}CreateRebillCustomer. According to this error, in response they need CreateRebillCustomerResponse but return CreateRebillCustomer object. the problem is that, how i change the object and where these objects are define ?.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!