Solved

Emergency Java Soap Problem need help please!!!!!!!!

Posted on 2010-09-18
9
1,175 Views
Last Modified: 2013-12-15
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:Header><wsa:ReplyTo><wsa:Address>http://www.w3.org/2005/08/addressing/none</wsa:Address><wsa:ReferenceParameters><axis2:ServiceGroupId xmlns:axis2="http://ws.apache.org/namespaces/axis2">urn:uuid:CBA8261DA843FDD4301284803860165</axis2:ServiceGroupId></wsa:ReferenceParameters></wsa:ReplyTo></soapenv:Header><soapenv:Body><LoginReport><Code v="-1"/><Text v="Authorization error!"/></LoginReport></soapenv:Body></soapenv: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.
0
Comment
Question by:3XLcom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 3

Expert Comment

by:tom_sebastian
ID: 33712282
Here is a working example using spring-ws.

you need spring, spring-ws, and axiom OR use the attached a maven pom file get the dependency jars
WebServiceTest.java
pom.xml
0
 
LVL 3

Expert Comment

by:tom_sebastian
ID: 33712284
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.springframework.ws.client.core.WebServiceTemplate;

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:login xmlns=\"\" xmlns:dgp=\"http://ws.dgpys.deloitte.com\">");
            requestStr.append("<loginMessage>");
            requestStr.append("<Password v=\"" + password + "\"/>");
            requestStr.append("<UserName v=\"" + username + "\"/>");
            requestStr.append("</loginMessage>");
            requestStr.append("</dgp:login>");
            Source requestPayload = new StreamSource(new ByteArrayInputStream(requestStr.toString().getBytes()));
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            Result responseResult = new StreamResult(bos);
            webService.sendSourceAndReceiveToResult(requestPayload, responseResult);
            return bos.toString();
      }

}
0
 

Author Comment

by:3XLcom
ID: 33712295
How did you add the web service as an Axis or Axis2 Client ?
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:3XLcom
ID: 33712302
Also what is webserviceTemplate in this code
0
 

Author Comment

by:3XLcom
ID: 33712318
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
0
 
LVL 3

Expert Comment

by:tom_sebastian
ID: 33713377
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.
0
 
LVL 3

Expert Comment

by:tom_sebastian
ID: 33713535
you enable Axis2 like this:
org.springframework.ws.soap.axiom.AxiomSoapMessageFactory soapMsgFactory = new AxiomSoapMessageFactory();
WebServiceTemplate webService = new WebServiceTemplate(soapMsgFactory);
0
 
LVL 3

Accepted Solution

by:
tom_sebastian earned 500 total points
ID: 33713588
org.springframework.ws.soap.axiom.AxiomSoapMessageFactory soapMsgFactory = new AxiomSoapMessageFactory();
WebServiceTemplate webService = new WebServiceTemplate(soapMsgFactory);
            
org.springframework.oxm.jaxb.Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setMtomEnabled(true);
marshaller.setContextPath("");//set the JAXB xml object context
webService.setMarshaller(marshaller);
webService.setUnmarshaller(marshaller);


webServiceTemplate.marshalSendAndReceive method can send and receive xml java objects instead of xml source.



0
 

Author Closing Comment

by:3XLcom
ID: 33866071
Thanks for all your help
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Which non-HTML GUI front end to use with Java? 3 67
Adding multiple JVM environments to RedHat 6 7 84
Java class and jar 3 61
batch vs regular insert in spring DAO 2 52
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question