Reputation: 275
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.
Upvotes: 1
Views: 1091
Reputation: 928
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
3) Click Browse and select WSDL address or local WSDL file
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
Upvotes: 3