You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by nilesh <ni...@slminfotech.com> on 2004/04/02 13:46:48 UTC

error calling .NET WebService using axis

Hi all,

i am using axis API for writting my SOAP Client. i need to call .NET based web service.

i have written the axis client but i am not sure is this a correct way..
The web service is using complextype..
public class New1TestClient {
   
public static String msg ="<SOAP-ENV:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"+
	"<SOAP-ENV:Body>\n"+
    "<AuthorisePayment xmlns=\"urn:nil:webservices/paymentauthorisation\">\n"+
    "<request>\n"+
    "<Input_Message xmlns=\"urn:nil:webservices:messageschemas/paymentauthorisation_input\">\n"+
    "<Operational xmlns=\"urn:nil:webservices:messageschemas/operational\">\n"+
	"<Application_Identification xmlns=\"urn:nil:webservices:messageschemas/operational\">\n"+
	"<AppId xmlns=\"urn:nil:webservices:messageschemas/operational\">A2G</AppId>\n"+
	"</Application_Identification>\n"+
	"</Operational>\n"+
    "<Data>\n"+
    "<Amount>100.00</Amount>"+
    "<CardNumber>00000000000000000000</CardNumber>"+
    "<DateExpiry>0105</DateExpiry>"+
    "<TxnType>P</TxnType>"+
    "<TxnRef>1234567812345678</TxnRef>"+
    "<DPSTxnRef>stringbbbbbbbbbb</DPSTxnRef>"+
    "</Data>"+
	"</Input_Message>"+
    "</request>"+
    "</AuthorisePayment>"+
  "</SOAP-ENV:Body>"+
"</SOAP-ENV:Envelope>";

	public static String test () throws Exception {
     
      String       url     = "http://nilesda/PayAuth2/PaymentAuthorisation_Stub.asmx";
      String       action  = "urn:nil:webservices/paymentauthorisation/AuthorisePayment" ;
        
       InputStream   input   = new ByteArrayInputStream(msg.getBytes());
      Service       service = new Service();
      Call          call    = (Call) service.createCall();
      SOAPEnvelope  env     = new SOAPEnvelope(input);

      call.setTargetEndpointAddress( new URL(url) );
      if (action != null) {
          call.setUseSOAPAction( true );
          call.setSOAPActionURI( action );
      }

      System.out.println( "Request:\n" + msg );

      env = call.invoke( env );

      System.out.println( "Response:\n" + env.toString() );
      return( env.toString() );
    }
    
  public static void main(String args[]) throws Exception{
    test();
  }
  
}

i tried to call the service but i an getting some error...

Server was unable to read request. --&gt; There is an error in XML document (13, 225). --&gt; The element 'urn:nil:webservices:messageschemas/paymentauthorisation_input:Input_Message' has invalid child element 'urn:nil:messageschemas/paymentauthorisation_input:Input_M
essage'. Expected 'urn:nil:webservices:messageschemas/operational:Operational'. An error occurred at , (1, 107).

i am providing u an my details of wsdl for my service...
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:s1="urn:nil:webservices:messageschemas/paymentauthorisation_input" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="urn:nil:webservices/paymentauthorisation" xmlns:s2="urn:nil:webservices:messageschemas/paymentauthorisation_output" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="urn:nil:webservices/paymentauthorisation" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <s:schema elementFormDefault="qualified" targetNamespace="urn:nil:webservices/paymentauthorisation">
      <s:import namespace="urn:nil:webservices:messageschemas/paymentauthorisation_input" />
      <s:import namespace="urn:nil:webservices:messageschemas/paymentauthorisation_output" />
      <s:element name="AuthorisePayment">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="request">
              <s:complexType>
                <s:sequence>
                  <s:any namespace="urn:nil:webservices:messageschemas/paymentauthorisation_input" />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="AuthorisePaymentResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="AuthorisePaymentResult">
              <s:complexType>
                <s:sequence>
                  <s:any namespace="urn:nil:webservices:messageschemas/paymentauthorisation_output" />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
    <s:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:opns="urn:nil:webservices:messageschemas/operational" xmlns:glns="urn:nil:webservices:messageschemas/globals" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:nil:webservices:messageschemas/paymentauthorisation_input" id="Input_Message">
      <xsd:import schemaLocation="Operational.xsd" namespace="urn:nil:webservices:messageschemas/operational" />
      <xsd:import schemaLocation="Globals.xsd" namespace="urn:nil:webservices:messageschemas/globals" />
      <xsd:element name="Input_Message">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element ref="opns:Operational" />
            <xsd:element name="Data">
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element name="Amount">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:decimal">
                        <xsd:pattern value="[0-9]{0,6}(\.[0-9]{0,2}){0,1}" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element name="CardNumber">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:pattern value="[0-9]{0,20}" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element name="DateExpiry">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:pattern value="(0[1-9]|(1[0,1,2]))([0-9]){2}" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element name="TxnType">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="1" />
                        <xsd:pattern value="P|R|A|C" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element name="TxnRef">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="16" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element minOccurs="0" name="DPSTxnRef">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="16" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                </xsd:sequence>
              </xsd:complexType>
            </xsd:element>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </s:schema>
    <s:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:glns="urn:nil:webservices:messageschemas/globals" xmlns:infns="urn:nil:webservices:messageschemas/information" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:nil:webservices:messageschemas/paymentauthorisation_output" id="Output_Message">
      <xsd:import schemaLocation="Globals.xsd" namespace="urn:nil:webservices:messageschemas/globals" />
      <xsd:import schemaLocation="Information.xsd" namespace="urn:nil:webservices:messageschemas/information" />
      <xsd:element name="Output_Message">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element minOccurs="0" name="Result">
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element minOccurs="0" name="Amount">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:decimal">
                        <xsd:pattern value="[0-9]{0,6}(\.[0-9]{0,2}){0,1}" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element minOccurs="0" name="AuthCode">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="64" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element name="TxnRef">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="16" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element minOccurs="0" name="TxnType">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="1" />
                        <xsd:pattern value="P|R|A|C" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element minOccurs="0" name="ResponseCode" type="xsd:int" />
                  <xsd:element minOccurs="0" name="MerchantResponseText">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="20" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                  <xsd:element minOccurs="0" name="DateSettlement" type="xsd:date" />
                  <xsd:element minOccurs="0" name="DPSTxnRef">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="16" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                </xsd:sequence>
              </xsd:complexType>
            </xsd:element>
            <xsd:element minOccurs="0" ref="infns:Status_Information" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </s:schema>
  </types>
  <message name="AuthorisePaymentSoapIn">
    <part name="parameters" element="s0:AuthorisePayment" />
  </message>
  <message name="AuthorisePaymentSoapOut">
    <part name="parameters" element="s0:AuthorisePaymentResponse" />
  </message>
  <portType name="PaymentAuthorisation_StubSoap">
    <operation name="AuthorisePayment">
      <input message="s0:AuthorisePaymentSoapIn" />
      <output message="s0:AuthorisePaymentSoapOut" />
    </operation>
  </portType>
  <portType name="PaymentAuthorisation_StubHttpGet" />
  <portType name="PaymentAuthorisation_StubHttpPost" />
  <binding name="PaymentAuthorisation_StubSoap" type="s0:PaymentAuthorisation_StubSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
    <operation name="AuthorisePayment">
      <soap:operation soapAction="urn:nil:webservices/paymentauthorisation/AuthorisePayment" style="document" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
  </binding>
  <binding name="PaymentAuthorisation_StubHttpGet" type="s0:PaymentAuthorisation_StubHttpGet">
    <http:binding verb="GET" />
  </binding>
  <binding name="PaymentAuthorisation_StubHttpPost" type="s0:PaymentAuthorisation_StubHttpPost">
    <http:binding verb="POST" />
  </binding>
  <service name="PaymentAuthorisation_Stub">
    <port name="PaymentAuthorisation_StubSoap" binding="s0:PaymentAuthorisation_StubSoap">
      <soap:address location="http://nilesda/paymentauthorisation_stub/paymentauthorisation_stub.asmx" />
    </port>
    <port name="PaymentAuthorisation_StubHttpGet" binding="s0:PaymentAuthorisation_StubHttpGet">
      <http:address location="http://nilesda/paymentauthorisation_stub/paymentauthorisation_stub.asmx" />
    </port>
    <port name="PaymentAuthorisation_StubHttpPost" binding="s0:PaymentAuthorisation_StubHttpPost">
      <http:address location="http://nilesda/paymentauthorisation_stub/paymentauthorisation_stub.asmx" />
    </port>
  </service>
</definitions>