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

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

Posted on 2010-09-18
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
 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/">
            <dgp:login xmlns="" xmlns:dgp="http://ws.dgpys.deloitte.com">
                        <Password v="denmee"/>
                        <UserName v="denneme"/>

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.
Question by:3XLcom
  • 5
  • 4

Expert Comment

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

Expert Comment

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) {
            try {
                  String result = login("denneme", "denmee");
            } catch (Exception e) {


      public static String login(String username, String password) throws Exception {
            WebServiceTemplate webService = new WebServiceTemplate();
            StringBuffer requestStr = new StringBuffer();
            requestStr.append("<dgp:login xmlns=\"\" xmlns:dgp=\"http://ws.dgpys.deloitte.com\">");
            requestStr.append("<Password v=\"" + password + "\"/>");
            requestStr.append("<UserName v=\"" + username + "\"/>");
            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();


Author Comment

ID: 33712295
How did you add the web service as an Axis or Axis2 Client ?
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Author Comment

ID: 33712302
Also what is webserviceTemplate in this code

Author Comment

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

Expert Comment

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.

Expert Comment

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

Accepted Solution

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.setContextPath("");//set the JAXB xml object context

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


Author Closing Comment

ID: 33866071
Thanks for all your help

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HashTable highest marks enumeration alternative 9 43
iterator/ListIterator approach 17 39
jboss wildfly 10.1 10 234
Eclipse Help Java EE 5,6,7 Documentation, why not Java EE 8 8 30
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

828 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