java.net.MalformedURLException:在createSOAPRequest方法没有协议
问题描述:
String url = "http://e2e-soaservices:44000/3.1/StandardDocumentService?wsdl";
//createSOAPRequest();
SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url);
: -java.net.MalformedURLException:在createSOAPRequest方法没有协议
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
File fXmlFile = new File("src/XML/gen_VDD7S0PLYPAS058_1409900400000_2.xml");
String xmlStr=finalXmlString(fXmlFile);
DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc=docBuilder.parse(xmlStr);
System.out.println("dasdasdasd"+doc.toString());
String serverURI = "http://www.aaancnuie.com/DCS/2012/01/DocumentCreation/IStandardDocumentService/CreateDocuments";
// SOAP Envelope
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("example", serverURI);
SOAPBody soapBody = envelope.getBody();
soapBody.setTextContent(xmlStr);
soapMessage.saveChanges();
return soapMessage;
控制台说,
java.net.MalformedURLException:没有协议
答
您需要encode
您的网址。 必须逃脱的特殊字符。
逃离例如:
String url = "http://e2e-soaservices:44000/3.1/StandardDocumentService?wsdl";
String yourURLStr = "java.net.URLEncoder.encode(url, "UTF-8");
java.net.URL url = new java.net.URL(yourURLStr);
@shekharsuman修正 – 2014-09-05 12:07:10
@ user3280711它帮助你 – 2014-09-05 12:09:31