Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://localhost:7159/chc2/services/WebServiceManager
- <wsdlsoap:address location="http://localhost:7159/chc2/services/WebServiceManager"/>
- <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
- <sws:dynamic-wsdl
- id="getemployeeDetails"
- portTypeName="EmpService"
- locationUri="/empService"
- targetNamespace="http://www.example.org/">
- <sws:xsd location="/WEB-INF/employee.xsd"/>
- </sws:dynamic-wsdl>
- import java.io.File;
- import java.io.IOException;
- import javax.xml.parsers.DocumentBuilder;
- import javax.xml.parsers.DocumentBuilderFactory;
- import javax.xml.parsers.ParserConfigurationException;
- import javax.xml.transform.Transformer;
- import javax.xml.transform.TransformerException;
- import javax.xml.transform.TransformerFactory;
- import javax.xml.transform.dom.DOMSource;
- import javax.xml.transform.stream.StreamResult;
- import org.w3c.dom.Document;
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
- import org.xml.sax.SAXException;
- public class WsdlDynamicPath {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- try {
- changePath();
- } catch (ParserConfigurationException | SAXException | IOException |
- TransformerException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public static void changePath() throws ParserConfigurationException, SAXException, IOException, TransformerException{
- String filepath = "path to wsdl\demo.wsdl"; //Give your wsdl file path
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
- Document doc = docBuilder.parse(filepath);
- Node address= doc.getElementsByTagName("soap:address").item(0);
- NamedNodeMap attr = address.getAttributes();
- Node nodeAttr = attr.getNamedItem("location");
- nodeAttr.setTextContent("new path to wsdl");
- // write the content into xml file
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- DOMSource source = new DOMSource(doc);
- StreamResult result = new StreamResult(new File(filepath));
- transformer.transform(source, result);
- }
- }
Add Comment
Please, Sign In to add comment