3XLcom
asked on
Emergency Java Soap Problem need help please!!!!!!!!
We need to get one info from a web service periodically.
But this service is not works for .net clients Service address is : http://dgpys.teias.gov.tr/dgpys/services/EVDServis?wsdl
There is a trick on the web service after adding the webservice client automatic generated code has a mistake :
instead of this 172.16.0.37
You need to write dgpys.teias.gov.tr
We tryed the service connection on Stylus Studio 2010 XML Enterprise Suite and it worked perfect. For example we send some xml like :
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<dgp:login xmlns="" xmlns:dgp="http://ws.dgpys.deloitte.com">
<loginMessage>
<Password v="denmee"/>
<UserName v="denneme"/>
</loginMessage>
</dgp:login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
And got an answer as this :
<?xml version="1.0" encoding="UTF-8"?><soapenv :Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"><soapenv:Head er><wsa:Re plyTo><wsa :Address>http://www.w3.org/2005/08/addressing/none< /wsa:Addre ss><wsa:Re ferencePar ameters><a xis2:Servi ceGroupId xmlns:axis2="http://ws.apache.org/namespaces/axis2">urn:uuid:CB A8261DA843 FDD4301284 803860165< /axis2:Ser viceGroupI d></wsa:Re ferencePar ameters></ wsa:ReplyT o></soapen v:Header>< soapenv:Bo dy><LoginR eport><Cod e v="-1"/><Text v="Authorization error!"/></LoginReport></s oapenv:Bod y></soapen v:Envelope >
This is all what we need a successfull working sample . Because we could not figure it out what if it is an Axis or Axis2 or JA-WS Connection. That is all what we need a working sample about how you connect to the service and got this result.
But this service is not works for .net clients Service address is : http://dgpys.teias.gov.tr/dgpys/services/EVDServis?wsdl
There is a trick on the web service after adding the webservice client automatic generated code has a mistake :
instead of this 172.16.0.37
You need to write dgpys.teias.gov.tr
We tryed the service connection on Stylus Studio 2010 XML Enterprise Suite and it worked perfect. For example we send some xml like :
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<dgp:login xmlns="" xmlns:dgp="http://ws.dgpys.deloitte.com">
<loginMessage>
<Password v="denmee"/>
<UserName v="denneme"/>
</loginMessage>
</dgp:login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
And got an answer as this :
<?xml version="1.0" encoding="UTF-8"?><soapenv
This is all what we need a successfull working sample . Because we could not figure it out what if it is an Axis or Axis2 or JA-WS Connection. That is all what we need a working sample about how you connect to the service and got this result.
import java.io.ByteArrayInputStre am;
import java.io.ByteArrayOutputStr eam;
import javax.xml.transform.Result ;
import javax.xml.transform.Source ;
import javax.xml.transform.stream .StreamRes ult;
import javax.xml.transform.stream .StreamSou rce;
import org.springframework.ws.cli ent.core.W ebServiceT emplate;
public class WebServiceTest {
/**
* @param args
*/
public static void main(String[] args) {
System.err.println("Test") ;
try {
String result = login("denneme", "denmee");
System.err.println(result) ;
} catch (Exception e) {
e.printStackTrace();
}
}
public static String login(String username, String password) throws Exception {
WebServiceTemplate webService = new WebServiceTemplate();
webService.setDefaultUri(" http://dgpys.teias.gov.tr:80/dgpys/services/EVDServis");
StringBuffer requestStr = new StringBuffer();
requestStr.append("<dgp:lo gin xmlns=\"\" xmlns:dgp=\"http://ws.dgpys.deloitte.com\">");
requestStr.append("<loginM essage>");
requestStr.append("<Passwo rd v=\"" + password + "\"/>");
requestStr.append("<UserNa me v=\"" + username + "\"/>");
requestStr.append("</login Message>") ;
requestStr.append("</dgp:l ogin>");
Source requestPayload = new StreamSource(new ByteArrayInputStream(reque stStr.toSt ring().get Bytes()));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Result responseResult = new StreamResult(bos);
webService.sendSourceAndRe ceiveToRes ult(reques tPayload, responseResult);
return bos.toString();
}
}
import java.io.ByteArrayOutputStr
import javax.xml.transform.Result
import javax.xml.transform.Source
import javax.xml.transform.stream
import javax.xml.transform.stream
import org.springframework.ws.cli
public class WebServiceTest {
/**
* @param args
*/
public static void main(String[] args) {
System.err.println("Test")
try {
String result = login("denneme", "denmee");
System.err.println(result)
} catch (Exception e) {
e.printStackTrace();
}
}
public static String login(String username, String password) throws Exception {
WebServiceTemplate webService = new WebServiceTemplate();
webService.setDefaultUri("
StringBuffer requestStr = new StringBuffer();
requestStr.append("<dgp:lo
requestStr.append("<loginM
requestStr.append("<Passwo
requestStr.append("<UserNa
requestStr.append("</login
requestStr.append("</dgp:l
Source requestPayload = new StreamSource(new ByteArrayInputStream(reque
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Result responseResult = new StreamResult(bos);
webService.sendSourceAndRe
return bos.toString();
}
}
ASKER
How did you add the web service as an Axis or Axis2 Client ?
ASKER
Also what is webserviceTemplate in this code
ASKER
Sir i^ve checked your solution this is about the send and receive just xml records but on the next step webservice returning ear formed tables so this won't be enough in my opinion for an axis2 webservice
WebServiceTemplate is a Spring-WS convenient class. you can configure axis2 message factory in the spring config. you can use marshaller too. add attachment because spring ws allows MTOM attachments too.
the sample code I added here is for the question asked. it will send exactly what you described in the problem with changed endpoint url. and get the exact response.
Spring-ws used SAAJ as default I guess, but you can always set a Axis2 message factory. Define a marshaller with MTOM enabled and set to webservice template.
the sample code I added here is for the question asked. it will send exactly what you described in the problem with changed endpoint url. and get the exact response.
Spring-ws used SAAJ as default I guess, but you can always set a Axis2 message factory. Define a marshaller with MTOM enabled and set to webservice template.
you enable Axis2 like this:
org.springframework.ws.soa p.axiom.Ax iomSoapMes sageFactor y soapMsgFactory = new AxiomSoapMessageFactory();
WebServiceTemplate webService = new WebServiceTemplate(soapMsg Factory);
org.springframework.ws.soa
WebServiceTemplate webService = new WebServiceTemplate(soapMsg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all your help
you need spring, spring-ws, and axiom OR use the attached a maven pom file get the dependency jars
WebServiceTest.java
pom.xml