When calling a SOAP web service, you can use a static call or a dynamic call.
A static call means creating a stub from the WSDL and using it to make the call. This creates all the “plumbing” code for you, but is closely tied to this web service, and you cannot use it for other web services with different contracts. For each WSDL you need to create another stub.
WSDL , - , WSDL. WSDL .
- , SoapUI .
WSDL, , XML- XML. Wsdl4j XmlBeans .
Wsdl4j , WSDL. XmlBeans; tools, , schema to .
(, , , ), API SoapUI:
import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlImporter;
public class Test {
public static void main(String[] args) throws Exception {
WsdlProject project = new WsdlProject();
WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx?wsdl");
WsdlInterface wsdl = wsdls[0];
System.out.println(wsdl.getOperationByName("Add").createRequest(true));
System.exit(0);
}
}
, ( WS), :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Add>
<tem:a>?</tem:a>
<tem:b>?</tem:b>
</tem:Add>
</soapenv:Body>
</soapenv:Envelope>
, .