0

I am trying to expose SOAP web service. For this I am using apache camel. So I have to use apache CXF to expose SOAP web service. But I am getting below error.

org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 223; The value of the attribute "prefix="xmlns",localpart="tns",rawname="xmlns:tns"" is invalid. Prefixed namespace bindings may not be empty.

This is following I have coded.

@WebService(endpointInterface="com.ericsson.fdp.SOAP.FulfillmentService", targetNamespace = "http://apache.org/hello_world_soap_http",portName="FulfillmentServicePort",serviceName="FulfillmentService")
public class FulfillmentServiceImpl implements FulfillmentService{


    @Produce(uri = "servlet:///fulfillmentService?servletName=FulfillmentService&matchOnUriPrefix=false")
    private ProducerTemplate template;

    @Override
    public FulfillmentResponse buyProduct(String input, String userName, String password, String msisdn, String iname) {

        Map<String,Object> queryMap = new HashMap<>();
        queryMap.put("input", input);
        queryMap.put("password", password);
        queryMap.put("msisdn", msisdn);
        queryMap.put("iname", iname);


        String response = (String) template.requestBodyAndHeaders(null, queryMap);
        FulfillmentResponse responseObject=null;
        try {
            responseObject = XmlUtil.unmarshall(response, FulfillmentResponse.class);
        } catch (JAXBException e) {
            e.printStackTrace();
        }
        return responseObject;
    }


}

This is interface for above implementation

@WebService(name="fulfillmentService", targetNamespace = "http://apache.org/hello_world_soap_http",portName="FulfillmentServicePort",serviceName="FulfillmentService")
public interface FulfillmentService {

    public FulfillmentResponse buyProduct(String input,String userName, String password,String msisdn,String iname);
}

I tried to check into. This is WSDL that is created for above code.

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="fulfillmentService" targetNamespace="" xmlns:ns2="http://schemas.xmlsoap.org/soap/http" xmlns:ns1="http://apache.org/hello_world_soap_http" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
  <wsdl:import namespace="http://apache.org/hello_world_soap_http" location="fulfillmentService.wsdl">
    </wsdl:import>
  <wsdl:binding name="fulfillmentServiceSoapBinding" type="ns1:fulfillmentService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="buyProduct">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="buyProduct">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="buyProductResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="fulfillmentService">
    <wsdl:port name="fulfillmentServicePort" binding="fulfillmentServiceSoapBinding">
      <soap:address location="http://127.0.0.1:8980/cisBusiness/services/fulFillment"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

How I can fix this error?

sdindiver
  • 491
  • 1
  • 5
  • 19

1 Answers1

0

Try adding same namespace to the following.

xmlns:tns="http://www.example.org" targetNamespace="http://www.example.org"

Ofcourse, you can change the "http://www.example.org" to something of your liking...

N0000B
  • 409
  • 1
  • 7
  • 16