Calling Orch exposed as a Web Service

Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Calling Orch exposed as a Web Service

Viewing 1 reply thread
  • Author
    Posts
    • #23736

      The steps I uses to expose the Orch as  a Web Service

      1) I have created a small Orch to recieve a message, map the same to another message and then send the same back, I have exposed the same as a Web Service.
      2) It has one Public Port, direction is receive a request and send a response, the receive port name is Port_RecOrder
      3) Deployed the Orchestration in the Visual Studio itself
      4) Published the Orch as a web Service
      5) In the Client App attached a web reference to the exposed web service
      6) now trying to call this web service using the below code ….

      public XmlDocument OrderDocument(XmlDocument xmlDoc)

      {

       

       

      XmlNode xnode = xmlDoc.SelectSingleNode(“/”);

      sendOrder.

      WebService_ConsureWebService ws = new sendOrder.WebService_ConsureWebServic();

      ws.Operation_1(

      ref xnode);

      }

      I am getting below 2 compile time errors:

      Error 1 The best overloaded method match for ‘sendOrder.WebService_ConsureWebService.Operation_1(ref sendOrder.Order)’ has some invalid arguments 

      Error 2 Argument ‘1’: cannot convert from ‘ref System.Xml.XmlNode’ to ‘ref sendOrder.Order’ 

       

      Please let me know If I am missout on some obvious things …

    • #23747

      I am using the below code snippet now to deserialize the XML document …

      [WebMethod]
      
      public XmlDocument OrderDocument(XmlDocument xmlDoc)
      
      {
      
      XmlSerializer serializer = new XmlSerializer(typeof(sendOrder.Order));
      
      string xmlString = xmlDoc.OuterXml.ToString();
      
      byte[] buffer = ASCIIEncoding.UTF8.GetBytes(xmlString);
      
      MemoryStream ms = new MemoryStream(buffer);
      
      sendOrder.Order orderDoc = (sendOrder.Order)serializer.Deserialize(ms);
      
      sendOrder.WebService_ConsureWebService ws = new sendOrder.WebService_ConsureWebService();
      
      ws.Operation_1(ref orderDoc);
      
      return xmlDoc;
      
      }
      
      

      While debugging I am getting the below exception:

      System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There is an error in XML document (1, 2). ---> System.InvalidOperationException: <Order xmlns='http://ConsureWebService.Order'> was not expected.
         at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderOrder.Read3_Order()
         --- End of inner exception stack trace ---
         at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
         at System.Xml.Serialization.XmlSerializer.Deserialize(Stream stream)
         at Service.OrderDocument(XmlDocument xmlDoc) in c:\Sugath\DoTNet Samples\WS Samples\ConsumeXML\App_Code\Service.cs:line 30
         --- End of inner exception stack trace ---
      
      

      The XML document I am passing is as below

      <ns0:Order xmlns:ns0="http://ConsureWebService.Order">
      <OrderId>OrderId_0</OrderId>
      <OrderName>OrderName_0</OrderName>
      </ns0:Order>
      

      Also, this is the sendOrder.Order object I am trying to deserialize to:

      namespace
      sendOrder
      {
          [Serializable]
          [XmlType(AnonymousType = true, Namespace = “http://ConsureWebService.Order&#8221;)]
          [GeneratedCode(“System.Xml”, “2.0.50727.3053”)]
          [DebuggerStepThrough]
          [DesignerCategory(“code”)]
          public class Order
          {
              public Order();

              public string OrderId { get; set; }
              public string OrderName { get; set; }
          }
      }

      Please do let know what is that I am missing out on ….

      • #23748

        Can anybody please tell what is wrong with the code, as the error says there is an error in the XML document but if you check the document I am passing and the even the Order object its got the same structure and the namespace

         There is an error in XML document (1, 2). —> System.InvalidOperationException: <Order xmlns=’http://ConsureWebService.Order’&gt; was not expected.

        • #23751
          [WebMethod]
          public XmlDocument OrderDocument(XmlDocument xmlDoc)
              {
                  XmlSerializer deserializer = new XmlSerializer(typeof(sendOrder.Order));
                  string xmlString = xmlDoc.OuterXml.ToString();
                  byte[] buffer = ASCIIEncoding.UTF8.GetBytes(xmlString);
                  MemoryStream ms = new MemoryStream(buffer);
                  XmlReader reader = new XmlTextReader(ms);
          
                  sendOrder.Order orderDoc = (sendOrder.Order)deserializer.Deserialize(reader);
          
                  sendOrder.WebService_ConsureWebService ws = new sendOrder.WebService_ConsureWebService();
                  ws.Operation_1(ref orderDoc);
          
                  return xmlDoc;
              }
          

          While Debugging I am getting null value for the reader even thou I can still find the document in the xmlDoc passed as a parameter, please do let me know

          • #23755

            GUYS any help … If you notice even the namespace and structure of the document is same … I am clueless as to why the below error is coming

            System.Web.Services.Protocols.SoapException: Server was unable to process request. —> System.InvalidOperationException: There is an error in XML document (1, 2). —> System.InvalidOperationException: <Order xmlns=’ConsureWebService.Order‘> was not expected.

            • #23757

              Hi,

               

                 It would help if you can publish the contents of your web service’s WSDL to help troubleshoot your problem. I might not be able to answer this, but other gurus might be…

               

                 Daniel.

               

              • #23758

                Below is the WSDL of the web service I am calling to ….

                <?

                 

                xml version=“1.0“ encoding=“utf-8“?>

                <

                 

                wsdl:definitions xmlns:soap=“http://schemas.xmlsoap.org/wsdl/soap/“ xmlns:tm=“http://microsoft.com/wsdl/mime/textMatching/“ xmlns:soapenc=“http://schemas.xmlsoap.org/soap/encoding/“ xmlns:mime=“http://schemas.xmlsoap.org/wsdl/mime/“ xmlns:tns=“http://tempuri.org/“ xmlns:s1=“http://ConsureWebService.Order“ xmlns:s=“http://www.w3.org/2001/XMLSchema“ xmlns:soap12=“http://schemas.xmlsoap.org/wsdl/soap12/“ xmlns:http=“http://schemas.xmlsoap.org/wsdl/http/“ targetNamespace=“http://tempuri.org/“ xmlns:wsdl=“http://schemas.xmlsoap.org/wsdl/“>

                <

                 

                wsdl:documentation xmlns:wsdl=“http://schemas.xmlsoap.org/wsdl/“>BizTalk assembly “ConsureWebService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e4898e48ff8ecc3e” published web service.</wsdl:documentation>

                <

                 

                wsdl:types>

                <

                 

                s:schema elementFormDefault=“qualified“ targetNamespace=“http://tempuri.org/“>

                <

                 

                s:import namespace=“http://ConsureWebService.Order“ />

                <

                 

                s:element name=“Operation_1“>

                <

                 

                s:complexType>

                <

                 

                s:sequence>

                <

                 

                s:element minOccurs=“0“ maxOccurs=“1“ ref=“s1:Order“ />

                </

                 

                s:sequence>

                </

                 

                s:complexType>

                </

                 

                s:element>

                <

                 

                s:element name=“Operation_1Response“>

                <

                 

                s:complexType>

                <

                 

                s:sequence>

                <

                 

                s:element minOccurs=“0“ maxOccurs=“1“ ref=“s1:Order“ />

                </

                 

                s:sequence>

                </

                 

                s:complexType>

                </

                 

                s:element>

                </

                 

                s:schema>

                <

                 

                s:schema elementFormDefault=“qualified“ targetNamespace=“http://ConsureWebService.Order“>

                <

                 

                s:element name=“Order“>

                <

                 

                s:complexType>

                <

                 

                s:sequence>

                <

                 

                s:element minOccurs=“0“ maxOccurs=“1“ form=“unqualified“ name=“OrderId“ type=“s:string“ />

                <

                 

                s:element minOccurs=“0“ maxOccurs=“1“ form=“unqualified“ name=“OrderName“ type=“s:string“ />

                </

                 

                s:sequence>

                </

                 

                s:complexType>

                </

                 

                s:element>

                </

                 

                s:schema>

                </

                 

                wsdl:types>

                <

                 

                wsdl:message name=“Operation_1SoapIn“>

                <

                 

                wsdl:part name=“parameters“ element=“tns:Operation_1“ />

                </

                 

                wsdl:message>

                <

                 

                wsdl:message name=“Operation_1SoapOut“>

                <

                 

                wsdl:part name=“parameters“ element=“tns:Operation_1Response“ />

                </

                 

                wsdl:message>

                <

                 

                wsdl:portType name=“WebService_ConsureWebServiceSoap“>

                <

                 

                wsdl:operation name=“Operation_1“>

                <

                 

                wsdl:input message=“tns:Operation_1SoapIn“ />

                <

                 

                wsdl:output message=“tns:Operation_1SoapOut“ />

                </

                 

                wsdl:operation>

                </

                 

                wsdl:portType>

                <

                 

                wsdl:binding name=“WebService_ConsureWebServiceSoap“ type=“tns:WebService_ConsureWebServiceSoap“>

                <

                 

                soap:binding transport=“http://schemas.xmlsoap.org/soap/http“ />

                <

                 

                wsdl:operation name=“Operation_1“>

                <

                 

                soap:operation soapAction=“http://tempuri.org/WebService_ConsureWebService/Operation_1“ style=“document“ />

                <

                 

                wsdl:input>

                <

                 

                soap:body use=“literal“ />

                </

                 

                wsdl:input>

                <

                 

                wsdl:output>

                <

                 

                soap:body use=“literal“ />

                </

                 

                wsdl:output>

                </

                 

                wsdl:operation>

                </

                 

                wsdl:binding>

                <

                 

                wsdl:binding name=“WebService_ConsureWebServiceSoap12“ type=“tns:WebService_ConsureWebServiceSoap“>

                <

                 

                soap12:binding transport=“http://schemas.xmlsoap.org/soap/http“ />

                <

                 

                wsdl:operation name=“Operation_1“>

                <

                 

                soap12:operation soapAction=“http://tempuri.org/WebService_ConsureWebService/Operation_1“ style=“document“ />

                <

                 

                wsdl:input>

                <

                 

                soap12:body use=“literal“ />

                </

                 

                wsdl:input>

                <

                 

                wsdl:output>

                <

                 

                soap12:body use=“literal“ />

                </

                 

                wsdl:output>

                </

                 

                wsdl:operation>

                </

                 

                wsdl:binding>

                <

                 

                wsdl:service name=“WebService_ConsureWebService“>

                <

                 

                wsdl:documentation xmlns:wsdl=“http://schemas.xmlsoap.org/wsdl/“>BizTalk assembly “ConsureWebService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e4898e48ff8ecc3e” published web service.</wsdl:documentation>

                <

                 

                wsdl:port name=“WebService_ConsureWebServiceSoap“ binding=“tns:WebService_ConsureWebServiceSoap“>

                <

                 

                soap:address location=“http://localhost:3693/ConsureWebService_Proxy/WebService_ConsureWebService.asmx“ />

                </

                 

                wsdl:port>

                <

                 

                wsdl:port name=“WebService_ConsureWebServiceSoap12“ binding=“tns:WebService_ConsureWebServiceSoap12“>

                <

                 

                soap12:address location=“http://localhost:3693/ConsureWebService_Proxy/WebService_ConsureWebService.asmx“ />

                </

                 

                wsdl:port>

                </

                 

                wsdl:service>

                </

                 

                wsdl:definitions>

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.