none
Exposing Biztalk REST service that accepts xml RRS feed

  • Question

  • Dear Team,

    my requirement is i want to expose a Biztalk REST service that accepts xml document and inside orchestration some business logic then i want to send it to another Rest service.

    Xml i want to receive is:

    <testDocumentdata>

      <testStudent1>

         <testelement1>abc</testelement1>

         <testelement2>abc</testelement2>

         <testelement3>abc</testelement3>

      </testStudent1>

      <testEMP1>

         <testEMPelement1>abc</testEMPelement1>

         <testEMPelement2>abc</testEMPelement2>

         <testEMPelement3>abc</testEMPelement3>

      </testEMP1>

      <element1>abc</element1>

      <element2>abc</element2>

    </testDocumentdata>

    Now in receive shape of orchestration  can i use this schema generated from well-formed xml?   (or) i need to use  system.xml.xmldocument?

    is there any target namespace issue bcoz in schema generally we use targetnamespace but client don't send any targetnamespace they just send above xml.

    please suggest.

    Also please provide any documentation how to receive xml in biztalk usig biztalk exposed REST service.

    Thank you.

    Monday, September 14, 2020 6:57 AM

All replies

  • It is no different from exposing a JSON rest service except you have a XML Decoder in your pipeline rather than a JSON one.

    In the orchestration it is usually better to use the schema.

    You can always map from a schema with no namespace to an internal one that does have a namespace.

    Give it a go, and if you have a specific issue, then we can help you. 

    Monday, September 14, 2020 9:01 AM
  • hi colin,

    part1)

    as per your guidelines,

    i have created schema without targetnamespace and used in  receive shape :

    see attached image 1.



    • Edited by DineshNad Monday, September 14, 2020 5:32 PM
    Monday, September 14, 2020 5:25 PM
  • continue.. part2

    now for temporary purpose i have returned same as response.

    deployed solution

    exposed  As Rest service.

    now http method and urlmapping in receive shape default value is:

    <BtsHttpUrlMapping><Operation Name='Op1' Url='' /><Operation Name='Op2' Url='/*' /></BtsHttpUrlMapping>  --working fine

    only value POST  --working fine

    but i want to map it to operation name with url value. tried below but no use

    <BtsHttpUrlMapping><Operation Name="Operation_1" Method="POST" Url="/EmpStuData" /></BtsHttpUrlMapping> <BtsHttpUrlMapping><Operation Name='Operation_1' Method='POST' Url='/EmpStuData' /></BtsHttpUrlMapping> <BtsHttpUrlMapping><Operation Name='Operation_1' Method='POST' Url='/Operation_1' /></BtsHttpUrlMapping>

    how to define http method and url mapping?

    Also i am getting response but the received xml i cant assign/use it in map, if i use map result is blank.


    • Edited by DineshNad Monday, September 14, 2020 5:33 PM
    Monday, September 14, 2020 5:28 PM
  • continue...part3

    assigned as:

    XML=indata;  --here XML is syste.xml.xmldocument message

    OutData=XML;    --here OutData same as received xml schema but has targetname space.

    but if i use OutData message in map no result xml its only empty


    • Edited by DineshNad Monday, September 14, 2020 5:33 PM
    Monday, September 14, 2020 5:31 PM
  • Well for starters your BtsHttpUrlMapping is all wrong.  There should be a single BtsHttpUrlMapping root, and each URL should be unique

    You will probably also want to have the Operations unique, and also meaningful.

    <BtsHttpUrlMapping>
    	<Operation Name="EmptStuData" Method="POST" Url="/EmpStuData" />
    	<Operation Name='Operation2' Method='POST' Url='/Operation_2' />
    	<Operation Name='Operation3' Method='POST' Url='/Operation_3' />
    </BtsHttpUrlMapping>

    Regarding your mapping, for the input to the map, you should also have a schema, that defines the XML payload without the namespace.  
    Monday, September 14, 2020 8:57 PM
  • Thanks colin,

    <BtsHttpUrlMapping><Operation Name="Operation_1" Method="POST" Url="/EmpStuData" />

    </BtsHttpUrlMapping> <BtsHttpUrlMapping><Operation Name='Operation_1' Method='POST' Url='/EmpStuData' />

    </BtsHttpUrlMapping> <BtsHttpUrlMapping><Operation Name='Operation_1' Method='POST' Url='/Operation_1' /></BtsHttpUrlMapping>

    above i have mentioned all possible combinations i tried , i have not used in one go in http method and urlmapping of receive port.

    Thanks now Map is working, i have directly used input message in Map input and in destination i have used schema with targetnamespace. now its working fine.

    now my url is:

    http://xx.xx.xx.xxx/RestWithXmlReceivePOST/Service1.svc

     and my orchestration is:

    i have only one method ,so how can i map in httpmethod and url mapping of receive port.

    i want to see my url like: http://xx.xx.xx.xxx/RestWithXmlReceivePOST/Service1.svc/updateData

    so url gives rest service feel.

    please confirm how to do this. also please explain these  Name="" Method="" Url="" 

    thank you

    Tuesday, September 15, 2020 5:02 AM
  • For an inbound port, it would match the URL and Method, and then assign the Operation that matches those to it.

    So your service is published as /RestWithXmlReceivePOST/Service1.svc in BizTalk

    Then you want your URI to be /updateData

    <BtsHttpUrlMapping>
    <Operation Name="Operation_1" Method="POST" Url="/updateData" />
    </BtsHttpUrlMapping>


    • Proposed as answer by Colin Dijkgraaf Wednesday, September 16, 2020 8:06 PM
    Wednesday, September 16, 2020 1:53 AM
  • Thanks Colin.

    its working fine.

    I have tried before posting question here with the following:

    <BtsHttpUrlMapping><Operation Name='Operation_1' Method='POST' Url='/EmpStuData' /></BtsHttpUrlMapping>

    /RestWithXmlReceivePOST/Service1.svc//EmpStuData 

     i tried above url but got following message in browser , so i have asked to explain.any how its working fine now thanks. i hope request xml missing so the following message. if i tried same in SOAPUI working fine

    <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
    - <Code>
      <Value>Sender</Value> 
    - <Subcode>
      <Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:DestinationUnreachable</Value> 
      </Subcode>
      </Code>
    - <Reason>
      <Text xml:lang="en-IN">The message with To '/TextXmlRcvREST/Service1.svc/updateData' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.</Text> 
      </Reason>
      </Fault>

    Thank you.

    Wednesday, September 16, 2020 6:56 AM
  • Hi colin

    in the above scenario i want to add security to REST service  , means username and password .

    Please suggest how can i do this.

    Wednesday, September 16, 2020 6:59 AM
  • Change the Authentication method to Basic in IIS on the web service.  You will need to set up local users with the username/password.
    Wednesday, September 16, 2020 8:05 PM