+ Start a Discussion
soasoa 

problem in webservice client

Hi.
 
I have created a web service which is adding two numbers.I generated a WSDL for the web service.
 
the code for the WSDL is :
 
Code:
<—xml version="1.0" encoding="UTF-8" standalone="yes"–>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.3.1-hudson-417-SNAPSHOT. -->
<definitions targetNamespace="http://PackAdd/" name="AddWSService" xmlns:tns="http://PackAdd/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <xs:schema version="1.0" targetNamespace="http://PackAdd/" xmlns:tns="http://PackAdd/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="AddNumbers" type="tns:AddNumbers"/>

  <xs:element name="AddNumbersResponse" type="tns:AddNumbersResponse"/>

  <xs:complexType name="AddNumbers">
    <xs:sequence>
      <xs:element name="a" type="xs:int"/>
      <xs:element name="b" type="xs:int"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="AddNumbersResponse">
    <xs:sequence>
      <xs:element name="return" type="xs:int"/>
    </xs:sequence>
  </xs:complexType>
    </xs:schema>
  </types>
  <message name="AddNumbers">
    <part name="parameters" element="tns:AddNumbers"/>
  </message>
  <message name="AddNumbersResponse">
    <part name="parameters" element="tns:AddNumbersResponse"/>
  </message>
  <portType name="AddWS">
    <operation name="AddNumbers">
      <input message="tns:AddNumbers"/>
      <output message="tns:AddNumbersResponse"/>
    </operation>
  </portType>
  <binding name="AddWSPortBinding" type="tns:AddWS">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <operation name="AddNumbers">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
  <service name="AddWSService">
    <port name="AddWSPort" binding="tns:AddWSPortBinding">
      <soap:address location="http://pc-p46799:8081/AddNumbers/AddWSService"/>
    </port>
  </service>
</definitions>


 
it created a client :
Code:
//Generated by wsdl2apex

public class packadd1 {
    public class AddWSPort {
        public String endpoint_x = 'http://pc-p46799:8081/AddNumbers/AddWSService';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        private String[] ns_map_type_info = new String[]{'http://PackAdd/', 'packadd1'};
        public Integer AddNumbers(Integer a,Integer b) {
            packadd1.AddNumbers request_x = new packadd1.AddNumbers();
            packadd1.AddNumbersResponse response_x;
            request_x.a = a;
            request_x.b = b;
            Map<String, packadd1.AddNumbersResponse> response_map_x = new Map<String, packadd1.AddNumbersResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://PackAdd/',
              'AddNumbers',
              'http://PackAdd/',
              'AddNumbersResponse',
              'packadd1.AddNumbersResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.return_x;
        }
    }
    public class AddNumbers {
        public Integer a;
        public Integer b;
        private String[] a_type_info = new String[]{'a','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] b_type_info = new String[]{'b','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://PackAdd/','false'};
        private String[] field_order_type_info = new String[]{'a','b'};
    }
    public class AddNumbersResponse {
        public Integer return_x;
        private String[] return_x_type_info = new String[]{'return','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://PackAdd/','false'};
        private String[] field_order_type_info = new String[]{'return_x'};
    }
}

 
i created a wrapper class which is calling the client :
the code is :
Code:
global class WSAddition {
WebService static Integer AddNumbers()
{
   Integer a = 44;
    Integer b = 54;
   

   packadd1.AddWSPort stub = new  packadd1.AddWSPort();
   Integer result = stub.AddNumbers(a, b);
   return(result);
}

}

 
i invoked this from a button . i am getting the folllowing error.
 
Web service Callout Failed : Unexpected Element:.Parser was expecting element
'http://schemas.xmlsoap.org/soap/envelop/:Envelop' but found' :html'
 
 
please help me...
where am i going wrong??
 
 
 
SuperfellSuperfell
Your service is returning an html document, not a soap response. this could be because your soap stack is converting an exception to a html error document, or it could be because the request is going to the wrong URL, or it could be because there's some network device like a firewall or proxy server returning a response and its never getting to your server.
SuperfellSuperfell
Or it could be because your WSDL contains a non publicly resolvable host name
http://pc-p46799:8081/AddNumbers/AddWSService

remember your service needs to be reachable via the internet.
r1985r1985

Simon,

          I am also facing the same error. So does it mean that the service can't be hosted within the network? I have my webservice in a local system. Is there any way to invoke it? Please share your thoughts on this.

 

Thanks,

Ram

SuperfellSuperfell
If you service is not accessible via the internet, then apex code (which is running on the salesforce.com server) cannot access it.
r1985r1985
Simon,
 
     Thanks for your response. Can we be able to view the SOAP request generated by salesforce? Because its saying
 
'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'.