I am working in Java first time using eclipse. I need to consume SOAP xml webservice in Java. I have wsdl and xsd schemas for the service. I have created the JASXB classes for the schema. I created a ServiceUtilty class that contains the Request and Response Objects. I am not sure if this is the correct approach. How to add header in the request?
import com.service.jaxb.provider.finddoc._2015.FindDocRequestType;
import com.service.jaxb.provider.finddoc._2015.FindDocResponseType;
public class testing {
private FindDocRequestType getFindDocResponseType()
{
FindDocRequestType findDocResponseType = new FindDocRequestType();
String Desc= findDocResponseType.getInfo().getFindDocOutputList().get(0).getDescr();
return findDocResponseType;
}
private FindDocRequestType getFindDocRequestType(String DocNo, string docId)
{
FindDocRequestType findDocRequestType = new FindDocRequestType();
findDocResponseType.setversion((short)12);
if(DocNo != null)
{
findDocRequestType.setDocNo(DocNo);
}
else if (docId != null)
{
findDocRequestType.setdocId(docId);
}
return findDocRequestType;
}
}
<soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/ xmlns:ns=http://service.bi.com/entity/message/2003/ xmlns:ns1=http://service.bi.com/provider/bi/biService/findBIDoc/2003/>
<soapenv:Header>
<ns:BIContext>
<messageId>89</messageId>
<creationTimestamp>2018-07-27T03:56:56.449Z</creationTimestamp>
<hostName>localhost</hostName>
</ns:BIContext>
</soapenv:Header>
<soapenv:Body>
<ns1:findBIDocRequest>
<ns:Version>13</ns:Version>
<docNumber>789999</docNumber>
<userId>test</userId>
<docId>88</docId>
</ns1:findBIDocRequest>
</soapenv:Body>
</soapenv:Envelope>