Preciso de ajuda para consumir meu WebService o mesmo tem o seguinte codigo SOAP
POST /webservice2/URANovoFax.asmx HTTP/1.1
Host: civic
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: “http://tempuri.org/RetornaMsg”
<soap:Envelope xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/”>
soap:Body
string
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<soap:Envelope xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/”>
soap:Body
int
</soap:Body>
</soap:Envelope>
Eu estou tentando acessar o mesmo com o seguinte código java:
package webservice;
import java.net.;
import java.io.;
public class WebService {
private static String strNome = "4031123456";
public static void main(String[] args) {
try {
String xmldata = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"+
"<soap:Body>"+
"<RetornaMsg xmlns=\"http://tempuri.org/\">"+
"<strNome>" +
strNome +
"</strNome>"+
"</RetornaMsg>"+
"</soap:Body>"+
"</soap:Envelope>";
String xmldata2 = "strNome=" + strNome;
//Create socket
String hostname = "civic";
int port = 80;
InetAddress addr = InetAddress.getByName(hostname);
Socket sock = new Socket(addr, port);
//Send header
String path = "/webservice2/URANovoFax.asmx";
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(),"UTF-8"));
// You can use "UTF8" for compatibility with the Microsoft virtual machine.
wr.write("POST " + path + " HTTP/1.0\r\n");
wr.write("Host: " + hostname + "\r\n");
wr.write("Content-Length: " + xmldata.length() + "\r\n");
wr.write("Content-Type: text/xml; charset=\"utf-8\"\r\n");
wr.write("SOAPAction: http://tempuri.org/RetornaMsg");
wr.write("\r\n");
//Send data
wr.write(xmldata);
wr.flush();
// Response
BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String line;
String resp="";
System.out.println("Request:");
System.out.println(xmldata.replace("><",">\n<"));
System.out.println("Response:");
while((line = rd.readLine()) != null){
resp+=line;
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Só que a resposta do servidor nunca vem.