1

I have created a Dynamic Web Project using Eclipse IDE, and the exposed web service method is given below, ie.CallPaySecure().

I want to know how to create a soap service which will accept soap-header as below.

<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <RequestorCredentials xmlns="https://paysecure/merchant.soap.header/"> <Version>string</Version> <UserCredentials> <UserID>string</UserID> <Password>string</Password> </UserCredentials> </RequestorCredentials> </soap:Header> <soap:Body> <CallPaySecure xmlns="https://paysecure/merchant.soap/"> <strCommand>string</strCommand> <strXML>string</strXML> </CallPaySecure> </soap:Body> </soap:Envelope>

I have written the following code in java

@WebMethod

@WebResult(name="CallPaySecureResult")

public String CallPaySecure(	@WebParam(name="strCommand")String strCmd,	@WebParam(name="strXML") String strXML ){ }

But this code can only get value from the following tags.

<strCommand>string</strCommand> <strXML>string</strXML>

1.My WSDL is auto generated by the Glassfish server v4, how can I modify the WSDL or what java code should I use to accept the above mentioned XML SOAP request?

2.How to define the <soap:Header> in the WSDL, so that I can access the values that comes in <Version>,<UserID> and <Password> in my web service CallPaySecure()?

I am using SOAP for the first time.

Thanks for the suggestions.

1

1 Answer 1

3

Generate Java client from WSDL using your IDE. Write your implementation logic in generated Java class file.

Fox example here is how you generate Java client from eclipse

1) Create Dynamic Web Project from File -> New ->Dynamic Web Project

2) Click on the project and open context menu New -> Other and from the window select Web service client

enter image description here

3) Click Browse and select WSDL address or local WSDL file enter image description here

4) Click Finish. All necessary java files will be generated in Dynamic web project

If you want to generate Java client without any IDE HERE is tutorial using wsimport

Sign up to request clarification or add additional context in comments.

2 Comments

This is correct, but far too sparse to be a good answer. Explain how to do it, in at least one IDE. You should also mention that generating Java from a WSDL is part of the JAX-WS standard (and by extension, the JAXB standard), and in fact can be done without any IDE using the wsimport tool that comes with every JDK.
Thank you @DatoMumladze I have done as you suggested please find the updated question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.