I am pretty new in SOAP web services in Java and I have the following problem.
I have a method that create the SOAP Envelop for a REQUEST , this one:
String soapXml = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"><soapenv:Header/><soapenv:Body><tem:getConfigSettings><tem:login>name.surname</tem:login><tem:password>myPassword</tem:password><tem:ipAddress>192.120.30.40</tem:ipAddress><tem:clientVersion>1</tem:clientVersion><tem:lastUpdateTime>1</tem:lastUpdateTime></tem:getConfigSettings></soapenv:Body></soapenv:Envelope>";
As you can see I put the SOAP REQUEST Envelop inside the soapXml string.
The problem is that when I put this XML inside this String object Eclipse marks this line as incorrect saying me the following error:
Multiple markers at this line
- Syntax error, insert ";" to complete Statement
- Line breakpoint:WebServiceHelper [line: 124] - authentication(String, String, String,
String)
Is it an error concerning how I have inserted the XML code inside a String? Or what? What can I do to solve?
Tnx
Andrea
The string you are inserting contains "
, terminating the initial string.
Escape every "
as \\"
inside your SOAP string.
WRONG:
String soapXml = "<soapenv:Envelope xmlns:soapenv="http://sc ... to be continued
CORRECT:
String soapXml = "<soapenv:Envelope xmlns:soapenv=\"http://sc ... to be continued
You need to escape the "
inside the strings like this \\"
String soapXml = "<soapenv:Envelope xmlns:"+
"soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\""+
"xmlns:tem=\"http://tempuri.org/\"><soapenv:Header/><soapenv:Body>"+
"<tem:getConfigSettings><tem:login>name.surname</tem:login>"+
"<tem:password>myPassword</tem:password><tem:ipAddress>192.120.30.40"+
"</tem:ipAddress><tem:clientVersion>1</tem:clientVersion>"+
"<tem:lastUpdateTime>1</tem:lastUpdateTime></tem:getConfigSettings>"+
"</soapenv:Body></soapenv:Envelope>";
More suitable example would be
String s = "hello";
String s2 = "\"hello\"";
System.out.println(s); => hello
System.out.println(s2); => "hello"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.