Loading ...
Sorry, an error occurred while loading the content.

using mssoap in vc++

Expand Messages
  • yugozheng
    Hi I am a c++ programmer and new to soap.I write my first soap client code, but it s seem s not work as it should be.Any help will be very appreciated. It use
    Message 1 of 2 , Oct 12, 2003
    • 0 Attachment
      Hi I am a c++ programmer and new to soap.I write my first soap
      client code, but it's seem's not work as it should be.Any help will
      be very appreciated.
      It use the zipcoderesolver service to get fullzipcode, see

      http://webservices.eraserver.net/zipcoderesolver/zipcoderesolver.asmx
      ?WSDL
      http://webservices.eraserver.net/zipcoderesolver/zipcoderesolver.asmx

      I only try the FullZipCode.

      the connection is ok, but I always output of 00000-0000, seems the
      soap message I send is incorrect, so I wondered is there anyone can
      tell me what wrong with the Serializer code in my program.

      here is the code and the soap message I got from mssoapT. BTW, my
      mssoapt not work as the MSDN soap FAQ said, I have to temporarily
      change the SVCNAME to local:8080 to get the soap message I send.
      where should I put the the xml file in local machine?

      #define
      SVCNAME "http://webservices.eraserver.net/zipcoderesolver/zipcodereso
      lver.asmx"
      //change to http://localhost:8080/... here when I want to get soap I
      send, but it doesn't help to get response the client receives.

      void CSoaptestDlg::OnGetzipcode()
      {
      // TODO: Add your control notification handler code here
      CoInitialize(NULL);

      ISoapSerializerPtr Serializer;
      ISoapReaderPtr Reader;
      ISoapConnectorPtr Connector;

      try
      {

      Connector.CreateInstance(__uuidof(HttpConnector));
      Connector->Property["EndPointURL"] = SVCNAME;
      Connector->Connect();
      Connector->Property["SoapAction"]
      = "http://webservices.eraserver.net/FullZipCode";
      Connector->BeginMessage();

      // Creating a SoapSerializer object and initializing it
      with InputSTream
      Serializer.CreateInstance(_uuidof(SoapSerializer));
      Serializer->Init(_variant_t((IUnknown*)Connector-
      >InputStream));

      //Write Message Here
      Serializer->startEnvelope("soap","","");
      Serializer->startBody("");
      Serializer->startElement
      ("FullZipCode","http://webservices.eraserver.net/","","");
      Serializer->startElement("accessCode","","","");
      Serializer->writeString("9999");
      Serializer->endElement();
      Serializer->startElement("address","","","");
      Serializer->writeString("111 N2nd St");
      Serializer->endElement();
      Serializer->startElement("city","","","");
      Serializer->writeString("Harrison");
      Serializer->endElement();
      Serializer->startElement("state","","","");
      Serializer->writeString("NJ");
      Serializer->endElement();
      Serializer->endElement();
      Serializer->endBody();
      Serializer->endEnvelope();

      Connector->EndMessage();

      Reader.CreateInstance(_uuidof(SoapReader));
      Reader->Load(_variant_t((IUnknown*)Connector-
      >OutputStream),"");
      SetResult((const char *)Reader->RPCResult->text);

      }

      catch(...)
      {
      SetResult("something wrong");
      }

      CoUninitialize();
      }
    • yugozheng
      and here is the message I get on mssoapt -
      Message 2 of 2 , Oct 12, 2003
      • 0 Attachment
        and here is the message I get on mssoapt
        <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
        - <soap:Envelope soap:encodingStyle=""
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        - <soap:Body soap:encodingStyle="">
        - <SOAPSDK1:FullZipCode
        xmlns:SOAPSDK1="http://webservices.eraserver.net/"
        soap:encodingStyle="">
        <accessCode soap:encodingStyle="">9999</accessCode>
        <address soap:encodingStyle="">111 N2nd St</address>
        <city soap:encodingStyle="">Harrison</city>
        <state soap:encodingStyle="">NJ</state>
        </SOAPSDK1:FullZipCode>
        </soap:Body>
        </soap:Envelope>
      Your message has been successfully submitted and would be delivered to recipients shortly.