Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Web Service Create Purchase Order , ConfigurePolicy Error

(0) ShareShare
ReportReport
Posted on by

We are facing an issue when we are sending a SOAP XML string to create a purchase Order From SOAP UI Editor , SOAP XML string is also attached , Please have a look .

Web service is working fine , we have tested this from Dot Net code. Also we have tested different GET methods , like GetCompayList etc , they are also working fine . The  issue we are facing is with SOAP XML string that we are passing from SOAP UI.

We are getting following Exception in GP Web service Exception Console.

"Object reference not set to an instance of an object.

  at Microsoft.Dynamics.Common.PolicyBusinessServiceImplementation.ConfigurePolicy(Context context, Policy consumerPolicy, Policy servicePolicy)"

If we click on "View Requested XML " we are getting following

"<?xml version="1.0"?>

<RequestObjects>

 <Policy xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema">

   <Key>

     <Id>c3b14f1e-b7b9-49c3-bce4-d1717bb5a4ab</Id>

   </Key>

   <Behaviors />

   <Name>Create Purchase Order Policy</Name>

   <RootBusinessObjectName>Purchasing Document</RootBusinessObjectName>

 </Policy>

</RequestObjects>

SOAP XML

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:soap="schemas.xmlsoap.org/.../" xmlns:m="schemas.microsoft.com/.../01" xmlns:ns="schemas.microsoft.com/.../01" xmlns:ns1="schemas.microsoft.com/.../01">

 <soap:Header>

 </soap:Header>

 <soap:Body>

   <m:CreatePurchaseOrder>

     <m:purchaseOrder>

       <m:Key>

         <m:CompanyKey>

           <ns:Id>-1</ns:Id>

         </m:CompanyKey>

         <m:Id>PO4077</m:Id>

       </m:Key>

       <m:Type>Standard</m:Type>

       <m:VendorKey>

         <m:CompanyKey>

           <ns:Id>-1</ns:Id>

         </m:CompanyKey>

         <m:Id>ACETRAVE0001</m:Id>

       </m:VendorKey>

       <m:Date>2014-04-17T00:00:00-04:00</m:Date>

       <m:DoesAllowSalesOrderCommitments>true</m:DoesAllowSalesOrderCommitments>

       <m:CreatedBy>WS_ADMINISTRATO</m:CreatedBy>

       <m:CompanyKey>

         <ns:Id>-1</ns:Id>

       </m:CompanyKey>

       <m:Lines>

         <m:PurchaseOrderLine>

           <m:WarehouseKey>

             <m:CompanyKey>

               <ns:Id>-1</ns:Id>

             </m:CompanyKey>

             <m:Id>WAREHOUSE</m:Id>

           </m:WarehouseKey>

           <m:VendorItemNumber>100XLG</m:VendorItemNumber>

           <m:ItemKey>

             <m:CompanyKey>

               <ns:Id>-1</ns:Id>

             </m:CompanyKey>

             <m:Id>100XLG</m:Id>

           </m:ItemKey>

           <m:QuantityOrdered>

             <m:Value>10</m:Value>

             <m:DecimalDigits>0</m:DecimalDigits>

           </m:QuantityOrdered>

         </m:PurchaseOrderLine>

       </m:Lines>

     </m:purchaseOrder>

     <m:context>

       <ns1:OrganizationKey>

         <m:CompanyKey>

           <ns:Id>-1</ns:Id>

         </m:CompanyKey>

       </ns1:OrganizationKey>

       <ns:CultureName>en-US</ns:CultureName>

       <ns:CurrencyType>Transactional</ns:CurrencyType>

       <ns:RoleKey>

         <ns1:Id>e18b321a-9548-48fb-b75a-dee0a618ddaa</ns1:Id>

       </ns:RoleKey>

     </m:context>

     <m:policy>

       <m:Key>

         <m:Id>c3b14f1e-b7b9-49c3-bce4-d1717bb5a4ab</m:Id>

       </m:Key>

        <m:Name>Create Purchase Order Policy</m:Name>

       <m:RootBusinessObjectName>Purchasing Document</m:RootBusinessObjectName>

     </m:policy>

   </m:CreatePurchaseOrder>

 </soap:Body>

</soap:Envelope>

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Web Service Create Purchase Order , ConfigurePolicy Error

    The Correct XML for context and Policy is

    <ns:context xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns="schemas.microsoft.com/.../01">

           <OrganizationKey xsi:type="CompanyKey">

             <Id>-1</Id>

           </OrganizationKey>

           <!--Optional:-->

           <ns1:CultureName>en-US</ns1:CultureName>

           <ns1:CurrencyType>Transactional</ns1:CurrencyType>

           <!--Optional:-->

         </ns:context>

         <!--Optional:-->

         <policy xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema">

           <Key>

             <Id>c3b14f1e-b7b9-49c3-bce4-d1717bb5a4ab</Id>

           </Key>

           <Behaviors />

           <Name>Create Purchase Order Policy</Name>

           <RootBusinessObjectName>Purchasing Document</RootBusinessObjectName>

         </policy>

    After doing this now I am able to create Purchase Order.

  • Kevin Day Profile Picture
    610 on at
    RE: Web Service Create Purchase Order , ConfigurePolicy Error

    This error message comes from the “WSExceptionLog” table when we call the “CreateCorporateAccount“ method in the  DynamicsGPWebServices web service:

    This is just a simple one with a Customer and a Parent Customer and the Company ID of 1 (which is a company, it is not 0 like the error says)

    BusinessObjectType:  Microsoft.Dynamics.Common.Policy

    ServiceType: ConfigurePolicy

    CompanyId: 0

    ExceptionMessage: Object reference not set to an instance of an object.

    ContextXML:  <?xml version="1.0"?>  <Context xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns="schemas.microsoft.com/.../01">    <CultureName>en-US</CultureName>    <CurrencyType>Transactional</CurrencyType>    <RoleKey>      <Id xmlns="schemas.microsoft.com/.../Id>    </RoleKey>  </Context>

    RequestXML

    <RequestObjects>  <Policy xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema">    <Key>      <Id>94880780-186c-43c8-b484-efcdd03cbdbf</Id>    </Key>    <Behaviors />    <Name> Create Corporate Account Policy </Name>    <RootBusinessObjectName>Customer</RootBusinessObjectName>  </Policy></RequestObjects>

  • Kevin Day Profile Picture
    610 on at
    RE: Web Service Create Purchase Order , ConfigurePolicy Error

    We are having the same exact issue, but just trying to push in a different document type.  Works in .Net, but same error in SoapUI.  Did you ever figure this one out?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans